public
Last active

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
index 4823883..f175d91 100644
--- a/tests/admin_widgets/tests.py
+++ b/tests/admin_widgets/tests.py
@@ -1,7 +1,7 @@
# encoding: utf-8
from __future__ import absolute_import, unicode_literals
-from datetime import datetime
+from datetime import datetime, timedelta, tzinfo
from django import forms
from django.conf import settings
@@ -13,7 +13,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile
from django.db.models import CharField, DateField
from django.test import TestCase as DjangoTestCase
from django.test.utils import override_settings
-from django.utils import six
+from django.utils import six, timezone
from django.utils import translation
from django.utils.html import conditional_escape
from django.utils.unittest import TestCase
@@ -519,6 +519,37 @@ class DateTimePickerSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
self.assertEqual(
self.get_css_value('#clockbox0', 'display'), 'none')
+ def test_date_time_picker_timezone(self):
+ self.admin_login(username='super', password='secret', login_url='/')
+
+ for zone in ['UTC', 'Asia/Singapore']:
+ with timezone.override(tzinfo(zone)):
+ now = timezone.now()
+ error_margin = timedelta(seconds=10)
+
+ self.selenium.get('%s%s' % (self.live_server_url,
+ '/admin_widgets/member/add/'))
+
+ self.selenium.find_element_by_id('id_name').send_keys(zone)
+
+ shortcuts = self.selenium.find_elements_by_css_selector(
+ '.field-birthdate .datetimeshortcuts')
+
+ for shortcut in shortcuts:
+ shortcut.find_element_by_tag_name('a').click()
+
+ import time
+ time.sleep(5)
+
+ self.selenium.find_element_by_tag_name('form').submit()
+
+ self.wait_page_loaded()
+
+ member = models.Member.objects.get(name=zone)
+ self.assertGreater(member.birthdate, now - error_margin)
+ self.assertLess(member.birthdate, now + error_margin)
+ member.delete()
+
class DateTimePickerSeleniumChromeTests(DateTimePickerSeleniumFirefoxTests):
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.