- {% include "_header.html" %}
- {% block page_header %}{% endblock %}
-
- {% include "horizon/_messages.html" %}
- {% block main %}{% endblock %}
- diff --git a/openstack_dashboard/static/bootstrap/img/glyphicons-halflings-white.png b/horizon/static/bootstrap/img/glyphicons-halflings-white.png similarity index 100% rename from openstack_dashboard/static/bootstrap/img/glyphicons-halflings-white.png rename to horizon/static/bootstrap/img/glyphicons-halflings-white.png diff --git a/openstack_dashboard/static/bootstrap/img/glyphicons-halflings.png b/horizon/static/bootstrap/img/glyphicons-halflings.png similarity index 100% rename from openstack_dashboard/static/bootstrap/img/glyphicons-halflings.png rename to horizon/static/bootstrap/img/glyphicons-halflings.png diff --git a/openstack_dashboard/static/bootstrap/js/bootstrap.js b/horizon/static/bootstrap/js/bootstrap.js similarity index 100% rename from openstack_dashboard/static/bootstrap/js/bootstrap.js rename to horizon/static/bootstrap/js/bootstrap.js diff --git a/openstack_dashboard/static/bootstrap/js/bootstrap.min.js b/horizon/static/bootstrap/js/bootstrap.min.js similarity index 100% rename from openstack_dashboard/static/bootstrap/js/bootstrap.min.js rename to horizon/static/bootstrap/js/bootstrap.min.js diff --git a/openstack_dashboard/static/bootstrap/less/accordion.less b/horizon/static/bootstrap/less/accordion.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/accordion.less rename to horizon/static/bootstrap/less/accordion.less diff --git a/openstack_dashboard/static/bootstrap/less/alerts.less b/horizon/static/bootstrap/less/alerts.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/alerts.less rename to horizon/static/bootstrap/less/alerts.less diff --git a/openstack_dashboard/static/bootstrap/less/bootstrap.less b/horizon/static/bootstrap/less/bootstrap.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/bootstrap.less rename to horizon/static/bootstrap/less/bootstrap.less diff --git a/openstack_dashboard/static/bootstrap/less/breadcrumbs.less b/horizon/static/bootstrap/less/breadcrumbs.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/breadcrumbs.less rename to horizon/static/bootstrap/less/breadcrumbs.less diff --git a/openstack_dashboard/static/bootstrap/less/button-groups.less b/horizon/static/bootstrap/less/button-groups.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/button-groups.less rename to horizon/static/bootstrap/less/button-groups.less diff --git a/openstack_dashboard/static/bootstrap/less/buttons.less b/horizon/static/bootstrap/less/buttons.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/buttons.less rename to horizon/static/bootstrap/less/buttons.less diff --git a/openstack_dashboard/static/bootstrap/less/carousel.less b/horizon/static/bootstrap/less/carousel.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/carousel.less rename to horizon/static/bootstrap/less/carousel.less diff --git a/openstack_dashboard/static/bootstrap/less/close.less b/horizon/static/bootstrap/less/close.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/close.less rename to horizon/static/bootstrap/less/close.less diff --git a/openstack_dashboard/static/bootstrap/less/code.less b/horizon/static/bootstrap/less/code.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/code.less rename to horizon/static/bootstrap/less/code.less diff --git a/openstack_dashboard/static/bootstrap/less/component-animations.less b/horizon/static/bootstrap/less/component-animations.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/component-animations.less rename to horizon/static/bootstrap/less/component-animations.less diff --git a/openstack_dashboard/static/bootstrap/less/dropdowns.less b/horizon/static/bootstrap/less/dropdowns.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/dropdowns.less rename to horizon/static/bootstrap/less/dropdowns.less diff --git a/openstack_dashboard/static/bootstrap/less/forms.less b/horizon/static/bootstrap/less/forms.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/forms.less rename to horizon/static/bootstrap/less/forms.less diff --git a/openstack_dashboard/static/bootstrap/less/grid.less b/horizon/static/bootstrap/less/grid.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/grid.less rename to horizon/static/bootstrap/less/grid.less diff --git a/openstack_dashboard/static/bootstrap/less/hero-unit.less b/horizon/static/bootstrap/less/hero-unit.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/hero-unit.less rename to horizon/static/bootstrap/less/hero-unit.less diff --git a/openstack_dashboard/static/bootstrap/less/labels.less b/horizon/static/bootstrap/less/labels.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/labels.less rename to horizon/static/bootstrap/less/labels.less diff --git a/openstack_dashboard/static/bootstrap/less/layouts.less b/horizon/static/bootstrap/less/layouts.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/layouts.less rename to horizon/static/bootstrap/less/layouts.less diff --git a/openstack_dashboard/static/bootstrap/less/mixins.less b/horizon/static/bootstrap/less/mixins.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/mixins.less rename to horizon/static/bootstrap/less/mixins.less diff --git a/openstack_dashboard/static/bootstrap/less/modals.less b/horizon/static/bootstrap/less/modals.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/modals.less rename to horizon/static/bootstrap/less/modals.less diff --git a/openstack_dashboard/static/bootstrap/less/navbar.less b/horizon/static/bootstrap/less/navbar.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/navbar.less rename to horizon/static/bootstrap/less/navbar.less diff --git a/openstack_dashboard/static/bootstrap/less/navs.less b/horizon/static/bootstrap/less/navs.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/navs.less rename to horizon/static/bootstrap/less/navs.less diff --git a/openstack_dashboard/static/bootstrap/less/pager.less b/horizon/static/bootstrap/less/pager.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/pager.less rename to horizon/static/bootstrap/less/pager.less diff --git a/openstack_dashboard/static/bootstrap/less/pagination.less b/horizon/static/bootstrap/less/pagination.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/pagination.less rename to horizon/static/bootstrap/less/pagination.less diff --git a/openstack_dashboard/static/bootstrap/less/popovers.less b/horizon/static/bootstrap/less/popovers.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/popovers.less rename to horizon/static/bootstrap/less/popovers.less diff --git a/openstack_dashboard/static/bootstrap/less/progress-bars.less b/horizon/static/bootstrap/less/progress-bars.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/progress-bars.less rename to horizon/static/bootstrap/less/progress-bars.less diff --git a/openstack_dashboard/static/bootstrap/less/reset.less b/horizon/static/bootstrap/less/reset.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/reset.less rename to horizon/static/bootstrap/less/reset.less diff --git a/openstack_dashboard/static/bootstrap/less/responsive.less b/horizon/static/bootstrap/less/responsive.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/responsive.less rename to horizon/static/bootstrap/less/responsive.less diff --git a/openstack_dashboard/static/bootstrap/less/scaffolding.less b/horizon/static/bootstrap/less/scaffolding.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/scaffolding.less rename to horizon/static/bootstrap/less/scaffolding.less diff --git a/openstack_dashboard/static/bootstrap/less/sprites.less b/horizon/static/bootstrap/less/sprites.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/sprites.less rename to horizon/static/bootstrap/less/sprites.less diff --git a/openstack_dashboard/static/bootstrap/less/tables.less b/horizon/static/bootstrap/less/tables.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/tables.less rename to horizon/static/bootstrap/less/tables.less diff --git a/openstack_dashboard/static/bootstrap/less/thumbnails.less b/horizon/static/bootstrap/less/thumbnails.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/thumbnails.less rename to horizon/static/bootstrap/less/thumbnails.less diff --git a/openstack_dashboard/static/bootstrap/less/tooltip.less b/horizon/static/bootstrap/less/tooltip.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/tooltip.less rename to horizon/static/bootstrap/less/tooltip.less diff --git a/openstack_dashboard/static/bootstrap/less/type.less b/horizon/static/bootstrap/less/type.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/type.less rename to horizon/static/bootstrap/less/type.less diff --git a/openstack_dashboard/static/bootstrap/less/utilities.less b/horizon/static/bootstrap/less/utilities.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/utilities.less rename to horizon/static/bootstrap/less/utilities.less diff --git a/openstack_dashboard/static/bootstrap/less/variables.less b/horizon/static/bootstrap/less/variables.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/variables.less rename to horizon/static/bootstrap/less/variables.less diff --git a/openstack_dashboard/static/bootstrap/less/wells.less b/horizon/static/bootstrap/less/wells.less similarity index 100% rename from openstack_dashboard/static/bootstrap/less/wells.less rename to horizon/static/bootstrap/less/wells.less diff --git a/openstack_dashboard/templates/_header.html b/horizon/templates/_header.html similarity index 100% rename from openstack_dashboard/templates/_header.html rename to horizon/templates/_header.html diff --git a/horizon/tests/templates/splash.html b/horizon/templates/_stylesheets.html similarity index 100% rename from horizon/tests/templates/splash.html rename to horizon/templates/_stylesheets.html diff --git a/openstack_dashboard/templates/auth/_login.html b/horizon/templates/auth/_login.html similarity index 100% rename from openstack_dashboard/templates/auth/_login.html rename to horizon/templates/auth/_login.html diff --git a/openstack_dashboard/templates/auth/login.html b/horizon/templates/auth/login.html similarity index 100% rename from openstack_dashboard/templates/auth/login.html rename to horizon/templates/auth/login.html diff --git a/openstack_dashboard/templates/base.html b/horizon/templates/base.html similarity index 100% rename from openstack_dashboard/templates/base.html rename to horizon/templates/base.html diff --git a/openstack_dashboard/templates/splash.html b/horizon/templates/splash.html similarity index 100% rename from openstack_dashboard/templates/splash.html rename to horizon/templates/splash.html diff --git a/horizon/test.py b/horizon/test.py index bc166fd01..e0844eb84 100644 --- a/horizon/test.py +++ b/horizon/test.py @@ -30,10 +30,12 @@ from django.contrib.messages.storage import default_storage from django.contrib.auth.middleware import AuthenticationMiddleware from django.core.handlers import wsgi from django.test.client import RequestFactory +from django.utils import unittest from glanceclient.v1 import client as glance_client from keystoneclient.v2_0 import client as keystone_client from novaclient.v1_1 import client as nova_client +from selenium.webdriver.firefox.webdriver import WebDriver import httplib2 import mox @@ -325,3 +327,19 @@ class APITestCase(TestCase): .AndReturn(self.swiftclient) expected_calls -= 1 return self.swiftclient + + +@unittest.skipUnless(os.environ.get('WITH_SELENIUM', False), + "The WITH_SELENIUM env variable is not set.") +class SeleniumTestCase(django_test.LiveServerTestCase): + @classmethod + def setUpClass(cls): + if os.environ.get('WITH_SELENIUM', False): + cls.selenium = WebDriver() + super(SeleniumTestCase, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(SeleniumTestCase, cls).tearDownClass() + if os.environ.get('WITH_SELENIUM', False): + cls.selenium.quit() diff --git a/horizon/tests/base_tests.py b/horizon/tests/base_tests.py index bcd9c0d5a..011eecded 100644 --- a/horizon/tests/base_tests.py +++ b/horizon/tests/base_tests.py @@ -49,14 +49,14 @@ class MyPanel(horizon.Panel): name = _("My Panel") slug = "myslug" permissions = ("openstack.services.compute",) - urls = 'horizon.tests.test_panel_urls' + urls = 'horizon.tests.test_dashboards.cats.kittens.urls' class AdminPanel(horizon.Panel): name = _("Admin Panel") slug = "admin_panel" permissions = ("openstack.roles.admin",) - urls = 'horizon.tests.test_panel_urls' + urls = 'horizon.tests.test_dashboards.cats.kittens.urls' class BaseHorizonTests(test.TestCase): @@ -256,6 +256,13 @@ class HorizonTests(BaseHorizonTests): panel = dash.get_panel('myslug') self._reload_urls() + # Set roles for admin user + self.setActiveUser(token=self.token, + username=self.user.name, + tenant_id=self.tenant.id, + service_catalog=self.request.user.service_catalog, + roles=[{'name': 'admin'}]) + # With the required service, the page returns fine. resp = self.client.get(panel.get_absolute_url()) self.assertEqual(resp.status_code, 200) diff --git a/horizon/tests/selenium_tests.py b/horizon/tests/selenium_tests.py new file mode 100644 index 000000000..f38118482 --- /dev/null +++ b/horizon/tests/selenium_tests.py @@ -0,0 +1,38 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2012 Nebula, Inc. +# +# 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 horizon import test + +import selenium.webdriver.support.ui as ui + + +class BrowserTests(test.SeleniumTestCase): + def test_splash(self): + self.selenium.get(self.live_server_url) + button = self.selenium.find_element_by_tag_name("button") + self.assertEqual(button.text, "Sign In") + + def test_qunit(self): + self.selenium.get("%s%s" % (self.live_server_url, "/qunit/")) + wait = ui.WebDriverWait(self.selenium, 10) + + def qunit_done(driver): + text = driver.find_element_by_id("qunit-testresult").text + return "Tests completed" in text + + wait.until(qunit_done) + failed = self.selenium.find_element_by_class_name("failed") + self.assertEqual(int(failed.text), 0) diff --git a/horizon/tests/templates/base.html b/horizon/tests/templates/base.html deleted file mode 100644 index d813b9a4b..000000000 --- a/horizon/tests/templates/base.html +++ /dev/null @@ -1,34 +0,0 @@ -{% load branding i18n %} - - -
- -' - 'This is a fake httpresponse from a fake view for testing ' - ' purposes only' - '
') - return resp diff --git a/horizon/views/__init__.py b/horizon/views/__init__.py index c70406d73..8868ee4a1 100644 --- a/horizon/views/__init__.py +++ b/horizon/views/__init__.py @@ -14,4 +14,4 @@ # License for the specific language governing permissions and limitations # under the License. -from .base import APIView, user_home +from .base import APIView, user_home, splash diff --git a/horizon/views/base.py b/horizon/views/base.py index 548fbf15b..2f48d5c2d 100644 --- a/horizon/views/base.py +++ b/horizon/views/base.py @@ -16,6 +16,9 @@ from django import shortcuts from django.views import generic +from django.views.decorators import vary + +from openstack_auth.views import Login import horizon from horizon import exceptions @@ -26,6 +29,22 @@ def user_home(request): return shortcuts.redirect(horizon.get_user_home(request.user)) +def get_user_home(user): + if user.is_superuser: + return horizon.get_dashboard('syspanel').get_absolute_url() + return horizon.get_dashboard('nova').get_absolute_url() + + +@vary.vary_on_cookie +def splash(request): + if request.user.is_authenticated(): + return shortcuts.redirect(get_user_home(request.user)) + form = Login(request) + request.session.clear() + request.session.set_test_cookie() + return shortcuts.render(request, 'splash.html', {'form': form}) + + class APIView(generic.TemplateView): """ A quick class-based view for putting API data into a template. diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 812d03f50..aceacb719 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -51,7 +51,7 @@ ROOT_URLCONF = 'openstack_dashboard.urls' HORIZON_CONFIG = { 'dashboards': ('nova', 'syspanel', 'settings',), 'default_dashboard': 'nova', - 'user_home': 'openstack_dashboard.views.user_home', + 'user_home': 'horizon.views.user_home', 'ajax_queue_limit': 10 } diff --git a/openstack_dashboard/static/dashboard/less/horizon.less b/openstack_dashboard/static/dashboard/less/horizon.less index 08b1ff75e..32a42577c 100644 --- a/openstack_dashboard/static/dashboard/less/horizon.less +++ b/openstack_dashboard/static/dashboard/less/horizon.less @@ -1,4 +1,4 @@ -@import "../../bootstrap/less/bootstrap.less"; +@import "../../../../horizon/static/bootstrap/less/bootstrap.less"; /* new clearfix */ .clearfix:after { diff --git a/openstack_dashboard/tests.py b/openstack_dashboard/tests.py deleted file mode 100644 index 8d941ce3e..000000000 --- a/openstack_dashboard/tests.py +++ /dev/null @@ -1,33 +0,0 @@ -import os - -from django import test -from django.utils import unittest - -from selenium.webdriver.firefox.webdriver import WebDriver - - -@unittest.skipUnless(os.environ.get('WITH_SELENIUM', False), - "The WITH_SELENIUM env variable is not set.") -class SeleniumTests(test.LiveServerTestCase): - @classmethod - def setUpClass(cls): - if os.environ.get('WITH_SELENIUM', False): - cls.selenium = WebDriver() - super(SeleniumTests, cls).setUpClass() - - @classmethod - def tearDownClass(cls): - super(SeleniumTests, cls).tearDownClass() - if os.environ.get('WITH_SELENIUM', False): - cls.selenium.quit() - - def test_splash(self): - self.selenium.get(self.live_server_url) - button = self.selenium.find_element_by_tag_name("button") - self.assertEqual(button.text, "Sign In") - - def test_qunit(self): - self.selenium.get("%s%s" % (self.live_server_url, "/qunit/")), - self.selenium.implicitly_wait("1000") - failed = self.selenium.find_element_by_class_name("failed") - self.assertEqual(int(failed.text), 0) diff --git a/openstack_dashboard/urls.py b/openstack_dashboard/urls.py index 76179b987..6d1a55e41 100644 --- a/openstack_dashboard/urls.py +++ b/openstack_dashboard/urls.py @@ -31,7 +31,7 @@ import horizon urlpatterns = patterns('', - url(r'^$', 'openstack_dashboard.views.splash', name='splash'), + url(r'^$', 'horizon.views.splash', name='splash'), url(r'^auth/', include('openstack_auth.urls')), url(r'', include(horizon.urls))) diff --git a/openstack_dashboard/views.py b/openstack_dashboard/views.py deleted file mode 100644 index 4dea550d6..000000000 --- a/openstack_dashboard/views.py +++ /dev/null @@ -1,44 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2012 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. -# All Rights Reserved. -# -# Copyright 2012 Nebula, Inc. -# -# 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. - -""" -Views for home page. -""" -from django import shortcuts -from django.views.decorators import vary - -import horizon -from openstack_auth.views import Login - - -def user_home(user): - if user.is_superuser: - return horizon.get_dashboard('syspanel').get_absolute_url() - return horizon.get_dashboard('nova').get_absolute_url() - - -@vary.vary_on_cookie -def splash(request): - if request.user.is_authenticated(): - return shortcuts.redirect(user_home(request.user)) - form = Login(request) - request.session.clear() - request.session.set_test_cookie() - return shortcuts.render(request, 'splash.html', {'form': form}) diff --git a/run_tests.sh b/run_tests.sh index 751e73791..fb5b05a8d 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -259,6 +259,10 @@ function install_venv { function run_tests { sanity_check + if [ $selenium -eq 1 ]; then + export WITH_SELENIUM=1 + fi + echo "Running Horizon application tests" export NOSE_XUNIT_FILE=horizon/nosetests.xml ${command_wrapper} coverage erase @@ -267,9 +271,6 @@ function run_tests { HORIZON_RESULT=$? echo "Running openstack_dashboard tests" - if [ $selenium -eq 1 ]; then - export WITH_SELENIUM=1 - fi export NOSE_XUNIT_FILE=openstack_dashboard/nosetests.xml ${command_wrapper} coverage run -p $root/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings $testargs # get results of the openstack_dashboard tests