From 48d36fa26fa1b3821819a9235828b47153a7bc5b Mon Sep 17 00:00:00 2001 From: Paul Van Eck Date: Thu, 10 Mar 2016 17:01:12 -0800 Subject: [PATCH] Refactor capabilities Rename the 'capabilities' endpoint to 'guidelines' to align more with DefCore terminology. Several references to 'capabilities' were thus updated to 'guidelines'. Split out the actual requests to the DefCore repository so that it can be used by other components. Also, the cache expiration time was increased to 12 hours from 10 minutes. Change-Id: I031798ffc32cdd66428af83a1ee610f00385c524 --- refstack-ui/app/app.js | 8 +- .../guidelines.html} | 10 +- .../guidelinesController.js} | 40 +++---- .../partials/guidelineDetails.html} | 18 +-- .../partials/testListModal.html | 0 .../partials/reportDetails.html | 10 +- .../results-report/resultsReport.html | 10 +- .../results-report/resultsReportController.js | 38 +++---- .../components/results/resultsController.js | 2 +- refstack-ui/app/index.html | 2 +- refstack-ui/app/shared/header/header.html | 2 +- refstack-ui/tests/unit/ControllerSpec.js | 39 +++---- refstack/api/controllers/capabilities.py | 86 --------------- refstack/api/controllers/guidelines.py | 54 +++++++++ refstack/api/controllers/v1.py | 4 +- refstack/api/guidelines.py | 103 ++++++++++++++++++ refstack/tests/api/test_api.py | 10 +- refstack/tests/unit/test_api.py | 97 +++++------------ refstack/tests/unit/test_guidelines.py | 90 +++++++++++++++ test-requirements.txt | 4 +- 20 files changed, 371 insertions(+), 256 deletions(-) rename refstack-ui/app/components/{capabilities/capabilities.html => guidelines/guidelines.html} (92%) rename refstack-ui/app/components/{capabilities/capabilitiesController.js => guidelines/guidelinesController.js} (88%) rename refstack-ui/app/components/{capabilities/partials/capabilityDetails.html => guidelines/partials/guidelineDetails.html} (73%) rename refstack-ui/app/components/{capabilities => guidelines}/partials/testListModal.html (100%) delete mode 100644 refstack/api/controllers/capabilities.py create mode 100644 refstack/api/controllers/guidelines.py create mode 100644 refstack/api/guidelines.py create mode 100644 refstack/tests/unit/test_guidelines.py diff --git a/refstack-ui/app/app.js b/refstack-ui/app/app.js index 5335e0c2..fc60145a 100644 --- a/refstack-ui/app/app.js +++ b/refstack-ui/app/app.js @@ -43,10 +43,10 @@ url: '/about', templateUrl: '/components/about/about.html' }). - state('capabilities', { - url: '/capabilities', - templateUrl: '/components/capabilities/capabilities.html', - controller: 'CapabilitiesController as ctrl' + state('guidelines', { + url: '/guidelines', + templateUrl: '/components/guidelines/guidelines.html', + controller: 'GuidelinesController as ctrl' }). state('communityResults', { url: '/community_results', diff --git a/refstack-ui/app/components/capabilities/capabilities.html b/refstack-ui/app/components/guidelines/guidelines.html similarity index 92% rename from refstack-ui/app/components/capabilities/capabilities.html rename to refstack-ui/app/components/guidelines/guidelines.html index aff6a8ef..ce0fe691 100644 --- a/refstack-ui/app/components/capabilities/capabilities.html +++ b/refstack-ui/app/components/guidelines/guidelines.html @@ -1,6 +1,6 @@

DefCore Guidelines

- +
Version: @@ -21,15 +21,15 @@

-
+
Guideline Status: - {{ctrl.capabilities.status | capitalize}} + {{ctrl.guidelines.status | capitalize}}
-
+
Corresponding OpenStack Releases:
    -
  • +
  • {{release | capitalize}}
diff --git a/refstack-ui/app/components/capabilities/capabilitiesController.js b/refstack-ui/app/components/guidelines/guidelinesController.js similarity index 88% rename from refstack-ui/app/components/capabilities/capabilitiesController.js rename to refstack-ui/app/components/guidelines/guidelinesController.js index 1c978f3e..976869e3 100644 --- a/refstack-ui/app/components/capabilities/capabilitiesController.js +++ b/refstack-ui/app/components/guidelines/guidelinesController.js @@ -17,16 +17,16 @@ angular .module('refstackApp') - .controller('CapabilitiesController', CapabilitiesController); + .controller('GuidelinesController', GuidelinesController); - CapabilitiesController.$inject = ['$http', '$uibModal', 'refstackApiUrl']; + GuidelinesController.$inject = ['$http', '$uibModal', 'refstackApiUrl']; /** - * RefStack Capabilities Controller - * This controller is for the '/capabilities' page where a user can browse + * RefStack Guidelines Controller + * This controller is for the '/guidelines' page where a user can browse * through tests belonging to DefCore-defined capabilities. */ - function CapabilitiesController($http, $uibModal, refstackApiUrl) { + function GuidelinesController($http, $uibModal, refstackApiUrl) { var ctrl = this; ctrl.getVersionList = getVersionList; @@ -51,11 +51,11 @@ /** * The template to load for displaying capability details. */ - ctrl.detailsTemplate = 'components/capabilities/partials/' + - 'capabilityDetails.html'; + ctrl.detailsTemplate = 'components/guidelines/partials/' + + 'guidelineDetails.html'; /** - * Retrieve an array of available capability files from the Refstack + * Retrieve an array of available guideline files from the Refstack * API server, sort this array reverse-alphabetically, and store it in * a scoped variable. The scope's selected version is initialized to * the latest (i.e. first) version here as well. After a successful API @@ -63,7 +63,7 @@ * Sample API return array: ["2015.03.json", "2015.04.json"] */ function getVersionList() { - var content_url = refstackApiUrl + '/capabilities'; + var content_url = refstackApiUrl + '/guidelines'; ctrl.versionsRequest = $http.get(content_url).success(function (data) { ctrl.versionList = data.sort().reverse(); @@ -78,19 +78,19 @@ /** * This will contact the Refstack API server to retrieve the JSON - * content of the capability file corresponding to the selected + * content of the guideline file corresponding to the selected * version. */ function update() { - var content_url = refstackApiUrl + '/capabilities/' + ctrl.version; + var content_url = refstackApiUrl + '/guidelines/' + ctrl.version; ctrl.capsRequest = $http.get(content_url).success(function (data) { - ctrl.capabilities = data; + ctrl.guidelines = data; ctrl.updateTargetCapabilities(); }).error(function (error) { ctrl.showError = true; - ctrl.capabilities = null; - ctrl.error = 'Error retrieving capabilities: ' + + ctrl.guidelines = null; + ctrl.error = 'Error retrieving guideline content: ' + angular.toJson(error); }); } @@ -103,14 +103,14 @@ */ function updateTargetCapabilities() { ctrl.targetCapabilities = {}; - var components = ctrl.capabilities.components; + var components = ctrl.guidelines.components; var targetCaps = ctrl.targetCapabilities; // The 'platform' target is comprised of multiple components, so // we need to get the capabilities belonging to each of its // components. if (ctrl.target === 'platform') { - var platform_components = ctrl.capabilities.platform.required; + var platform_components = ctrl.guidelines.platform.required; // This will contain status priority values, where lower // values mean higher priorities. @@ -189,12 +189,12 @@ * the selected status(es). */ function getTestList() { - var caps = ctrl.capabilities.capabilities; + var caps = ctrl.guidelines.capabilities; var tests = []; angular.forEach(ctrl.targetCapabilities, function (status, cap) { if (ctrl.status[status]) { - if (ctrl.capabilities.schema === '1.2') { + if (ctrl.guidelines.schema === '1.2') { tests.push.apply(tests, caps[cap].tests); } else { @@ -214,7 +214,7 @@ */ function openTestListModal() { $uibModal.open({ - templateUrl: '/components/capabilities/partials' + + templateUrl: '/components/guidelines/partials' + '/testListModal.html', backdrop: true, windowClass: 'modal', @@ -249,7 +249,7 @@ /** * Test List Modal Controller * This controller is for the modal that appears if a user wants to see the - * ftest list corresponding to DefCore capabilities with the selected + * test list corresponding to DefCore capabilities with the selected * statuses. */ function TestListModalController($uibModalInstance, $window, tests, diff --git a/refstack-ui/app/components/capabilities/partials/capabilityDetails.html b/refstack-ui/app/components/guidelines/partials/guidelineDetails.html similarity index 73% rename from refstack-ui/app/components/capabilities/partials/capabilityDetails.html rename to refstack-ui/app/components/guidelines/partials/guidelineDetails.html index 9cf49ae0..c0a9f49b 100644 --- a/refstack-ui/app/components/capabilities/partials/capabilityDetails.html +++ b/refstack-ui/app/components/guidelines/partials/guidelineDetails.html @@ -1,11 +1,11 @@ -
    -
  1. +
      +
    1. {{capability.id}}
      {{capability.description}}
      Status: {{ctrl.targetCapabilities[capability.id]}}
      @@ -19,11 +19,11 @@ variable 'capabilities'. Tests ({{ctrl.getObjectLength(capability.tests)}})
        -
      • +
      • {{test}}
      • -
      • +
      • {{testName}}
        @@ -35,12 +35,12 @@ variable 'capabilities'.
    -
    +

    Criteria

      -
    • +
    • {{criterion.name}}
      {{criterion.Description}}
      Weight: {{criterion.weight}} diff --git a/refstack-ui/app/components/capabilities/partials/testListModal.html b/refstack-ui/app/components/guidelines/partials/testListModal.html similarity index 100% rename from refstack-ui/app/components/capabilities/partials/testListModal.html rename to refstack-ui/app/components/guidelines/partials/testListModal.html diff --git a/refstack-ui/app/components/results-report/partials/reportDetails.html b/refstack-ui/app/components/results-report/partials/reportDetails.html index 25a3c971..a0c8b1ce 100644 --- a/refstack-ui/app/components/results-report/partials/reportDetails.html +++ b/refstack-ui/app/components/results-report/partials/reportDetails.html @@ -21,7 +21,7 @@ report page. ng-if="ctrl.isCapabilityShown(capability)"> + title="{{ctrl.guidelineData.capabilities[capability.id].description}}"> {{capability.id}} + ctrl.isTestFlagged(test, ctrl.guidelineData.capabilities[capability.id])}" + title="{{ctrl.getFlaggedReason(test, ctrl.guidelineData.capabilities[capability.id])}}"> {{test}}
    • @@ -63,8 +63,8 @@ report page. + ctrl.isTestFlagged(test, ctrl.guidelineData.capabilities[capability.id])}" + title="{{ctrl.getFlaggedReason(test, ctrl.guidelineData.capabilities[capability.id])}}"> {{test}} diff --git a/refstack-ui/app/components/results-report/resultsReport.html b/refstack-ui/app/components/results-report/resultsReport.html index 9a280524..84960e5d 100644 --- a/refstack-ui/app/components/results-report/resultsReport.html +++ b/refstack-ui/app/components/results-report/resultsReport.html @@ -36,7 +36,7 @@ Guideline Version: @@ -53,20 +53,20 @@
      -
      +
      Guideline Status: - {{ctrl.capabilityData.status | capitalize}} + {{ctrl.guidelineData.status | capitalize}}
      Corresponding OpenStack Releases:
        -
      • +
      • {{release | capitalize}}

      -
      +
      Status:

      This cloud passes {{ctrl.requiredPassPercent | number:1}}% ({{ctrl.caps.required.passedCount}}/{{ctrl.caps.required.count}}) diff --git a/refstack-ui/app/components/results-report/resultsReportController.js b/refstack-ui/app/components/results-report/resultsReportController.js index 3f71b026..b92ab280 100644 --- a/refstack-ui/app/components/results-report/resultsReportController.js +++ b/refstack-ui/app/components/results-report/resultsReportController.js @@ -40,7 +40,7 @@ ctrl.isShared = isShared; ctrl.shareTestRun = shareTestRun; ctrl.deleteTestRun = deleteTestRun; - ctrl.updateCapabilities = updateCapabilities; + ctrl.updateGuidelines = updateGuidelines; ctrl.getTargetCapabilities = getTargetCapabilities; ctrl.buildCapabilityV1_2 = buildCapabilityV1_2; ctrl.buildCapabilityV1_3 = buildCapabilityV1_3; @@ -66,7 +66,7 @@ 'object': 'OpenStack Powered Object Storage' }; - /** The schema version of the currently selected capabilities data. */ + /** The schema version of the currently selected guideline data. */ ctrl.schemaVersion = null; /** The selected test status used for test filtering. */ @@ -77,7 +77,7 @@ 'reportDetails.html'; /** - * Retrieve an array of available capability files from the Refstack + * Retrieve an array of available guideline files from the Refstack * API server, sort this array reverse-alphabetically, and store it in * a scoped variable. The scope's selected version is initialized to * the latest (i.e. first) version here as well. After a successful API @@ -85,14 +85,14 @@ * Sample API return array: ["2015.03.json", "2015.04.json"] */ function getVersionList() { - var content_url = refstackApiUrl + '/capabilities'; + var content_url = refstackApiUrl + '/guidelines'; ctrl.versionsRequest = $http.get(content_url).success(function (data) { ctrl.versionList = data.sort().reverse(); if (!ctrl.version) { ctrl.version = ctrl.versionList[0]; } - ctrl.updateCapabilities(); + ctrl.updateGuidelines(); }).error(function (error) { ctrl.showError = true; ctrl.error = 'Error retrieving version list: ' + @@ -189,24 +189,24 @@ /** * This will contact the Refstack API server to retrieve the JSON - * content of the capability file corresponding to the selected + * content of the guideline file corresponding to the selected * version. A function to construct an object from the capability - * date will be called upon successful retrieval. + * data will be called upon successful retrieval. */ - function updateCapabilities() { - ctrl.capabilityData = null; + function updateGuidelines() { + ctrl.guidelineData = null; ctrl.showError = false; - var content_url = refstackApiUrl + '/capabilities/' + + var content_url = refstackApiUrl + '/guidelines/' + ctrl.version; ctrl.capsRequest = $http.get(content_url).success(function (data) { - ctrl.capabilityData = data; + ctrl.guidelineData = data; ctrl.schemaVersion = data.schema; ctrl.buildCapabilitiesObject(); }).error(function (error) { ctrl.showError = true; - ctrl.capabilityData = null; - ctrl.error = 'Error retrieving capabilities: ' + + ctrl.guidelineData = null; + ctrl.error = 'Error retrieving guideline date: ' + angular.toJson(error); }); } @@ -217,7 +217,7 @@ * @returns {Object} Object containing each capability and their status */ function getTargetCapabilities() { - var components = ctrl.capabilityData.components; + var components = ctrl.guidelineData.components; var targetCaps = {}; // The 'platform' target is comprised of multiple components, so @@ -225,7 +225,7 @@ // components. if (ctrl.target === 'platform') { var platform_components = - ctrl.capabilityData.platform.required; + ctrl.guidelineData.platform.required; // This will contain status priority values, where lower // values mean higher priorities. @@ -285,7 +285,7 @@ 'passedFlagged': [], 'notPassedFlagged': [] }; - var capDetails = ctrl.capabilityData.capabilities[capId]; + var capDetails = ctrl.guidelineData.capabilities[capId]; // Loop through each test belonging to the capability. angular.forEach(capDetails.tests, function (testId) { @@ -322,7 +322,7 @@ 'notPassedFlagged': [] }; // Loop through each test belonging to the capability. - angular.forEach(ctrl.capabilityData.capabilities[capId].tests, + angular.forEach(ctrl.guidelineData.capabilities[capId].tests, function (details, testId) { var passed = false; @@ -390,8 +390,8 @@ break; default: ctrl.showError = true; - ctrl.capabilityData = null; - ctrl.error = 'The schema version for the capabilities ' + + ctrl.guidelineData = null; + ctrl.error = 'The schema version for the guideline ' + 'file selected (' + ctrl.schemaVersion + ') is currently not supported.'; return; diff --git a/refstack-ui/app/components/results/resultsController.js b/refstack-ui/app/components/results/resultsController.js index 4c0bc51b..c3f14829 100644 --- a/refstack-ui/app/components/results/resultsController.js +++ b/refstack-ui/app/components/results/resultsController.js @@ -196,7 +196,7 @@ if (ctrl.versionList) { return; } - var content_url = refstackApiUrl + '/capabilities'; + var content_url = refstackApiUrl + '/guidelines'; ctrl.versionsRequest = $http.get(content_url).success(function (data) { ctrl.versionList = data.sort().reverse(); diff --git a/refstack-ui/app/index.html b/refstack-ui/app/index.html index 5b5f94c9..24f403d5 100644 --- a/refstack-ui/app/index.html +++ b/refstack-ui/app/index.html @@ -38,7 +38,7 @@ - + diff --git a/refstack-ui/app/shared/header/header.html b/refstack-ui/app/shared/header/header.html index a4cdb134..89cbc690 100644 --- a/refstack-ui/app/shared/header/header.html +++ b/refstack-ui/app/shared/header/header.html @@ -17,7 +17,7 @@ RefStack