diff --git a/AUTHORS b/AUTHORS index 9e688b1..5eaccd0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -3,3 +3,4 @@ Eddie Ramirez Eddie Ramirez Luis Daniel Castellanos Revon Mathews +ldcastell diff --git a/ChangeLog b/ChangeLog index 22cd0d4..05cea60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ CHANGES ======= +* Add JavaScript unit tests code base * Move the panel dashboard outside of the project section * Removed the docstrings from the start of file * Removed PEP8 errors diff --git a/README.rst b/README.rst index e049153..226d3c7 100644 --- a/README.rst +++ b/README.rst @@ -3,13 +3,14 @@ Craton UI for Horizon Dashboard =============================== Test -____ +---- -* Python tests: `./run_test.sh` +* Python tests: ``./run_test.sh`` * JS tests: - 1. `npm install` (first do `./run_tests.sh` to create virtual environment) - 2. `npm run lint` for eslint - 3. `npm run test` for JS unit tests + + 1. ``npm install`` (first do ``./run_tests.sh`` to create virtual environment) + 2. ``npm run lint`` for eslint + 3. ``npm run test`` for JS unit tests Install ------- @@ -24,4 +25,3 @@ From http://docs.openstack.org/developer/horizon/tutorials/plugin.html 2. Run “cp -rv enabled horizon/openstack_dashboard/local/” 3. Run “horizon/tools/with_venv.sh pip install dist/package.tar.gz” 4. Restart Apache or your Django test server - diff --git a/craton_dashboard/api/craton.py b/craton_dashboard/api/craton.py index d68704e..c0c90e9 100644 --- a/craton_dashboard/api/craton.py +++ b/craton_dashboard/api/craton.py @@ -13,8 +13,8 @@ # limitations under the License. -from cratonclient.v1 import client as craton_client from cratonclient import session as craton_session +from cratonclient.v1 import client as craton_client from horizon.utils.memoized import memoized # noqa from horizon.utils.memoized import memoized_with_request # noqa diff --git a/craton_dashboard/api/rest/__init__.py b/craton_dashboard/api/rest/__init__.py index e69de29..778d56e 100644 --- a/craton_dashboard/api/rest/__init__.py +++ b/craton_dashboard/api/rest/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2016 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from craton_dashboard.api.rest import craton # noqa \ No newline at end of file diff --git a/craton_dashboard/content/fleet_management/inventory/__init__.py b/craton_dashboard/content/fleet_management/inventory/__init__.py index e69de29..930d0b5 100644 --- a/craton_dashboard/content/fleet_management/inventory/__init__.py +++ b/craton_dashboard/content/fleet_management/inventory/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2016 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from craton_dashboard.api import rest # noqa diff --git a/craton_dashboard/content/fleet_management/inventory/views.py b/craton_dashboard/content/fleet_management/inventory/views.py index d0b4695..5080e69 100644 --- a/craton_dashboard/content/fleet_management/inventory/views.py +++ b/craton_dashboard/content/fleet_management/inventory/views.py @@ -17,5 +17,5 @@ from django.views import generic class IndexView(generic.TemplateView): - template_name = 'fleet_management/inventory/index.html' + template_name = 'angular.html' page_title = _('Inventory') diff --git a/craton_dashboard/content/fleet_management/taskflows/__init__.py b/craton_dashboard/content/fleet_management/taskflows/__init__.py index e69de29..930d0b5 100644 --- a/craton_dashboard/content/fleet_management/taskflows/__init__.py +++ b/craton_dashboard/content/fleet_management/taskflows/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2016 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from craton_dashboard.api import rest # noqa diff --git a/craton_dashboard/content/fleet_management/taskflows/views.py b/craton_dashboard/content/fleet_management/taskflows/views.py index 66cca27..3b2c88d 100644 --- a/craton_dashboard/content/fleet_management/taskflows/views.py +++ b/craton_dashboard/content/fleet_management/taskflows/views.py @@ -17,5 +17,5 @@ from django.views import generic class IndexView(generic.TemplateView): - template_name = 'fleet_management/taskflows/index.html' + template_name = 'angular.html' page_title = _('Taskflows') diff --git a/craton_dashboard/static/app/core/openstack-service-api/craton.service.js b/craton_dashboard/static/app/core/openstack-service-api/craton.service.js index 6cb3d6d..6ff7876 100644 --- a/craton_dashboard/static/app/core/openstack-service-api/craton.service.js +++ b/craton_dashboard/static/app/core/openstack-service-api/craton.service.js @@ -31,11 +31,12 @@ .factory('horizon.app.core.openstack-service-api.craton', cratonAPI); cratonAPI.$inject = [ + '$q', 'horizon.framework.util.http.service', 'horizon.framework.widgets.toast.service' ]; - function cratonAPI(apiService, toastService) { + function cratonAPI($q, apiService, toastService) { var service = { getRegions: getRegions }; @@ -51,8 +52,8 @@ .error(function error() { toastService.add('error', gettext("Unable to get the Craton regions listing")); }); - } + } return service; } diff --git a/craton_dashboard/static/dashboard/project/fleet_management/fleet_management.module.spec.js b/craton_dashboard/static/dashboard/project/fleet_management/fleet_management.module.spec.js index bc6c983..cec9c7e 100644 --- a/craton_dashboard/static/dashboard/project/fleet_management/fleet_management.module.spec.js +++ b/craton_dashboard/static/dashboard/project/fleet_management/fleet_management.module.spec.js @@ -17,6 +17,10 @@ (function() { 'use strict'; - //TODO: ADD Tests!! + describe('horizon.dashboard.project.fleet_management', function() { + it('should be defined',function test() { + expect(angular.module('horizon.dashboard.project.fleet_management')).toBeDefined(); + }); + }); })(); diff --git a/craton_dashboard/static/dashboard/project/fleet_management/fleet_managment.module.js b/craton_dashboard/static/dashboard/project/fleet_management/fleet_managment.module.js index 23151c7..9e852df 100644 --- a/craton_dashboard/static/dashboard/project/fleet_management/fleet_managment.module.js +++ b/craton_dashboard/static/dashboard/project/fleet_management/fleet_managment.module.js @@ -19,51 +19,52 @@ /** * @ngdoc overview - * @name horizon.dashboard.project + * @name horizon.dashboard.project.fleet_management * * @description * Dashboard module to host various backup panels. */ angular - .module('horizon.dashboard.project.fleet_management', []) + .module('horizon.dashboard.project.fleet_management', [ + 'horizon.dashboard.project.fleet_management.regions' + ]) .config(config); config.$inject = [ '$provide', - '$windowProvider', - '$routeProvider' + '$windowProvider' ]; - function config($provide, $windowProvider, $routeProvider) { + function config($provide, $windowProvider) { var basePath = $windowProvider.$get().STATIC_URL + 'dashboard/project/fleet_management/'; $provide.constant('horizon.dashboard.project.fleet_management.basePath', basePath); - var regions = '/project/regions'; - var taskflows = '/project/fleet/taskflows'; - var alerts = '/project/fleet/alerts'; - var auditor = '/project/fleet/auditor'; - var reporting = '/project/fleet/reporting'; - var inventory = '/project/fleet/inventory'; - - $routeProvider - .when(regions, { - templateUrl: basePath + 'regions/index.html' - }) - .when(taskflows, { - templateUrl: basePath + 'taskflows/index.html' - }) - .when(alerts, { - templateUrl: basePath + 'alerts/index.html' - }) - .when(auditor, { - templateUrl: basePath + 'auditor/index.html' - }) - .when(reporting, { - templateUrl: basePath + 'reporting/index.html' - }) - .when(inventory, { - templateUrl: basePath + 'inventory/index.html' - }); + // var regions = '/project/regions'; + // var taskflows = '/project/fleet/taskflows'; + // var alerts = '/project/fleet/alerts'; + // var auditor = '/project/fleet/auditor'; + // var reporting = '/project/fleet/reporting'; + // var inventory = '/project/fleet/inventory'; + // + // $routeProvider + // .when(regions, { + // templateUrl: basePath + 'regions/index.html' + // }) + // .when(taskflows, { + // templateUrl: basePath + 'taskflows/index.html' + // }) + // .when(alerts, { + // templateUrl: basePath + 'alerts/index.html' + // }) + // .when(auditor, { + // templateUrl: basePath + 'auditor/index.html' + // }) + // .when(reporting, { + // templateUrl: basePath + 'reporting/index.html' + // }) + // .when(inventory, { + // templateUrl: basePath + 'inventory/index.html' + // }); } })(); diff --git a/craton_dashboard/static/dashboard/project/fleet_management/inventory/details/drawer.html b/craton_dashboard/static/dashboard/project/fleet_management/inventory/details/drawer.html new file mode 100644 index 0000000..ca1eb28 --- /dev/null +++ b/craton_dashboard/static/dashboard/project/fleet_management/inventory/details/drawer.html @@ -0,0 +1,5 @@ +
+
+ +
+
\ No newline at end of file diff --git a/craton_dashboard/static/dashboard/project/fleet_management/inventory/panel.html b/craton_dashboard/static/dashboard/project/fleet_management/inventory/panel.html new file mode 100644 index 0000000..529e886 --- /dev/null +++ b/craton_dashboard/static/dashboard/project/fleet_management/inventory/panel.html @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/craton_dashboard/static/dashboard/project/fleet_management/inventory/regions.module.js b/craton_dashboard/static/dashboard/project/fleet_management/inventory/regions.module.js new file mode 100644 index 0000000..ca73a53 --- /dev/null +++ b/craton_dashboard/static/dashboard/project/fleet_management/inventory/regions.module.js @@ -0,0 +1,90 @@ +/** + * Copyright 2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + /** + * @ngdoc Craton Regions module for fleet managament + * + * @name horizon.dashboard.project.fleet_management.regions + * + * @description + * Provides services and widgets required to support and display + * fleet management regions content + */ + + angular + .module('horizon.dashboard.project.fleet_management.regions', ['ngRoute']) + .constant('horizon.dashboard.project.fleet_management.resourceType', 'OS::Craton::Region') + .run(run) + .config(config); + + run.$inject = [ + 'horizon.framework.conf.resource-type-registry.service', + 'horizon.app.core.openstack-service-api.craton', + 'horizon.dashboard.project.fleet_management.basePath', + 'horizon.dashboard.project.fleet_management.resourceType' + ]; + + function run(registry, craton, basePath, cratonResourceType) { + registry.getResourceType(cratonResourceType) + .setNames(gettext('Region'), gettext('Regions')) + .setSummaryTemplateUrl(basePath + 'inventory/details/drawer.html') + .setProperty('name', {label: gettext('Name')}) + .setProperty('id', {label: gettext('ID')}) + .setProperty('note', {label: gettext('Note')}) + .setProperty('project_id', {label:gettext('Project ID')}) + .setListFunction(listFunction) + .tableColumns + .append({ + id: 'name', + priority: 1, + sortDefault: true + }) + .append({ + id: 'id', + priority: 1 + }) + .append({ + id: 'note', + priority: 2 + }) + .append({ + id: 'project_id', + priority: 3 + }); + + function listFunction() { + return craton.getRegions(); + } + } + + config.$inject = [ + '$provide', + '$windowProvider', + '$routeProvider' + ]; + + function config($provide, $windowProvider, $routeProvider) { + var path = $windowProvider.$get().STATIC_URL + 'dashboard/project/fleet_management/inventory/'; + $provide.constant('horizon.dashboard.project.fleet_management.regions.basePath', path); + + $routeProvider.when('/fleet_management/', { + templateUrl: path + 'panel.html' + }); + } +})(); diff --git a/craton_dashboard/static/dashboard/project/fleet_management/inventory/regions.module.spec.js b/craton_dashboard/static/dashboard/project/fleet_management/inventory/regions.module.spec.js new file mode 100644 index 0000000..bec1c24 --- /dev/null +++ b/craton_dashboard/static/dashboard/project/fleet_management/inventory/regions.module.spec.js @@ -0,0 +1,26 @@ +/** + * Copyright 2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + describe('horizon.dashboard.project.fleet_management.regions', function () { + it('should be defined', function test() { + expect(angular.module('horizon.dashboard.project.fleet_management.regions')).toBeDefined(); + }); + }); + +})(); diff --git a/karma.conf.js b/karma.conf.js index 8357208..aa8fd57 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -128,6 +128,7 @@ module.exports = function(config) { * not significant. */ './craton_dashboard/static/app/core/**/*.module.js', + './craton_dashboard/static/dashboard/**/**/**/*.module.js', /** * Followed by other JavaScript files that defines angular providers @@ -136,23 +137,27 @@ module.exports = function(config) { * significant. */ './craton_dashboard/static/app/core/**/!(*.spec|*.mock).js', + './craton_dashboard/static/dashboard/**/**/**/!(*.spec|*.mock).js', /** * Then, list files for mocks with `mock.js` extension. The order * among them should not be significant. */ './craton_dashboard/static/app/core/**/*.mock.js', + './craton_dashboard/static/dashboard/**/**/**/*.mock.js', /** * Finally, list files for spec with `spec.js` extension. The order * among them should not be significant. */ './craton_dashboard/static/app/core/**/*.spec.js', + './craton_dashboard/static/dashboard/**/**/**/*.spec.js', /** * Angular external templates */ - './craton_dashboard/static/app/core/**/*.html' + './craton_dashboard/static/app/core/**/*.html', + './craton_dashboard/static/dashboard/**/**/**/*.html' ], autoWatch: true,