summaryrefslogtreecommitdiff
path: root/horizon/test
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-03-03 19:39:59 +0000
committerGerrit Code Review <review@openstack.org>2016-03-03 19:39:59 +0000
commit66ea48a69f67c32601d398b657936846c147ea4d (patch)
tree798337ea63b8b9c5e1d78829dedafc313ffb7c1a /horizon/test
parent46c71761196c3dff4261d9ef085ad7bacc9c17c0 (diff)
parent9749d873a6243a8cf000f6eae58d5d2c2ed43106 (diff)
downloadhorizon-66ea48a69f67c32601d398b657936846c147ea4d.tar.gz
Merge "Fixing timezone awareness"9.0.0.0b3
Diffstat (limited to 'horizon/test')
-rw-r--r--horizon/test/tests/middleware.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/horizon/test/tests/middleware.py b/horizon/test/tests/middleware.py
index 4b80b9ae7..694824b3d 100644
--- a/horizon/test/tests/middleware.py
+++ b/horizon/test/tests/middleware.py
@@ -16,6 +16,7 @@
from django.conf import settings
from django.http import HttpResponseRedirect # noqa
+from django.utils import timezone
from horizon import exceptions
from horizon import middleware
@@ -23,6 +24,15 @@ from horizon.test import helpers as test
class MiddlewareTests(test.TestCase):
+
+ def setUp(self):
+ self._timezone_backup = timezone.get_current_timezone_name()
+ return super(MiddlewareTests, self).setUp()
+
+ def tearDown(self):
+ timezone.activate(self._timezone_backup)
+ return super(MiddlewareTests, self).tearDown()
+
def test_redirect_login_fail_to_login(self):
url = settings.LOGIN_URL
request = self.factory.post(url)
@@ -49,3 +59,19 @@ class MiddlewareTests(test.TestCase):
resp = mw.process_response(request, response)
self.assertEqual(200, resp.status_code)
self.assertEqual(url, resp['X-Horizon-Location'])
+
+ def test_timezone_awareness(self):
+ url = settings.LOGIN_REDIRECT_URL
+ mw = middleware.HorizonMiddleware()
+
+ request = self.factory.get(url)
+ request.session['django_timezone'] = 'America/Chicago'
+ mw.process_request(request)
+ self.assertEqual(
+ timezone.get_current_timezone_name(), 'America/Chicago')
+ request.session['django_timezone'] = 'Europe/Paris'
+ mw.process_request(request)
+ self.assertEqual(timezone.get_current_timezone_name(), 'Europe/Paris')
+ request.session['django_timezone'] = 'UTC'
+ mw.process_request(request)
+ self.assertEqual(timezone.get_current_timezone_name(), 'UTC')