From d833ddb9d41a181eaf2c4cc1ecfa39ecd8c79bdb Mon Sep 17 00:00:00 2001 From: Thai Tran Date: Wed, 6 May 2015 13:51:04 -0700 Subject: [PATCH] Fixing Jasmine tests in dashboard We currently have two jasmine tests, one in horizon and one in dashboard. We currently use two different templates and they are out of sync with each other. Furthermore, we should extend the sources list, not override it, because dashboard modules depends on code in horizon. This patch fixes these issues. Closes-bug: #1452446 Change-Id: I3fcbb1ea30b5e83a16f94fb31959270bd393593a --- .../templates/jasmine/index.html | 15 ---- .../templates/jasmine/jasmine.html | 85 ------------------- openstack_dashboard/test/jasmine/jasmine.py | 4 +- .../test/jasmine/jasmine_tests.py | 21 +++-- 4 files changed, 16 insertions(+), 109 deletions(-) delete mode 100644 openstack_dashboard/templates/jasmine/index.html delete mode 100644 openstack_dashboard/templates/jasmine/jasmine.html diff --git a/openstack_dashboard/templates/jasmine/index.html b/openstack_dashboard/templates/jasmine/index.html deleted file mode 100644 index 3082deb73a..0000000000 --- a/openstack_dashboard/templates/jasmine/index.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - Jasmine Spec Runner Index - -

Available tests

- - - - diff --git a/openstack_dashboard/templates/jasmine/jasmine.html b/openstack_dashboard/templates/jasmine/jasmine.html deleted file mode 100644 index 46cf002210..0000000000 --- a/openstack_dashboard/templates/jasmine/jasmine.html +++ /dev/null @@ -1,85 +0,0 @@ -{% load url from future %} - - - - Jasmine Spec Runner - - - - - - - - - - - - - - - - - - {% for file in sources %} - - {% endfor %} - - - {% for file in specs %} - - {% endfor %} - - - {% for file in HORIZON_CONFIG.js_files %} - - {% endfor %} - - - {% for file in HORIZON_CONFIG.js_spec_files %} - - {% endfor %} - - - - - - - - diff --git a/openstack_dashboard/test/jasmine/jasmine.py b/openstack_dashboard/test/jasmine/jasmine.py index 102b78945b..f72304d340 100644 --- a/openstack_dashboard/test/jasmine/jasmine.py +++ b/openstack_dashboard/test/jasmine/jasmine.py @@ -30,7 +30,7 @@ def dispatcher(request, test_name): if not test_name: return django.shortcuts.render( request, - "jasmine/index.html", + "horizon/jasmine/index.html", {'classes': (cls_name for cls_name, _ in classes)} ) else: @@ -39,7 +39,7 @@ def dispatcher(request, test_name): template = cls.template_name if not template: - template = "jasmine/jasmine.html" + template = "horizon/jasmine/jasmine.html" return django.shortcuts.render( request, diff --git a/openstack_dashboard/test/jasmine/jasmine_tests.py b/openstack_dashboard/test/jasmine/jasmine_tests.py index 81a911369e..a12919d048 100644 --- a/openstack_dashboard/test/jasmine/jasmine_tests.py +++ b/openstack_dashboard/test/jasmine/jasmine_tests.py @@ -14,14 +14,16 @@ # under the License. -from horizon.test import helpers as test +from horizon.test.jasmine import jasmine_tests as test LAUNCH_INST = "dashboard/launch-instance" -class ServicesTests(test.JasmineTests): - # sources would go here - sources = [ +class ServicesTests(test.ServicesTests): + + # We rely on sources from horizon + # therefore, we must append the sources + dashboard_sources = [ 'dashboard/dashboard.module.js', 'dashboard/workflow/workflow.js', LAUNCH_INST + '/launch-instance.js', @@ -33,7 +35,9 @@ class ServicesTests(test.JasmineTests): LAUNCH_INST + '/network/network.js', LAUNCH_INST + '/source/source.js', ] - # spec files would go here + + # We are only testing dashboard specs here + # so we override the parent specs specs = [ 'dashboard/dashboard.module.js', 'dashboard/workflow/workflow.js', @@ -46,5 +50,8 @@ class ServicesTests(test.JasmineTests): LAUNCH_INST + '/network/network.spec.js', LAUNCH_INST + '/source/source.spec.js', ] - externalTemplates = [ - ] + externalTemplates = [] + + def __init__(self, *args, **kwargs): + super(test.ServicesTests, self).__init__(*args, **kwargs) + self.sources = self.sources.extend(self.dashboard_sources)