summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hill <dhill@redhat.com>2019-04-02 11:57:29 -0400
committerIvan Kolodyazhny <e0ne@e0ne.info>2021-04-07 10:18:29 +0000
commitcd16b4079e6bf222518893002b73396295b3101f (patch)
treefa159a6601aceb0d5fe66e965b32fd45dabe8583
parent35103d9c65a3b00150f13cbe129c1fc13cd120fb (diff)
downloadhorizon-cd16b4079e6bf222518893002b73396295b3101f.tar.gz
Get the timezone offset for the current day instead of January 1st.
This bug only appears to be a cosmetic one where the TZ offset would be calculated on current_year/01/01 so would remain in daylight saving offset when displaying the timezones list. (Note by amotoki) The minimum version of Babel is bumped to 2.6.0 as Babel 2.3.4 returns "New Zealand Time" instead of "New Zealand (Auckland) Time" returned from the latest Babel (2.9.0). It is not a good idea to handle such difference in Babel in our UT and there is no reason to stick to Bump 2.3.4. 2.6.0 was chosen as it is available in Ubuntu Focal and there is no more reason than this. Change-Id: I0600086cc51cf5abcf1631565e75146114189667 Closes-bug: #1822849 (cherry picked from commit f60220329accd9c6492acfc25fe024c394e3eaea)
-rw-r--r--lower-constraints.txt5
-rw-r--r--openstack_dashboard/dashboards/settings/user/forms.py3
-rw-r--r--openstack_dashboard/dashboards/settings/user/tests.py13
-rw-r--r--releasenotes/notes/bug-1822849-2833b5e6a5d021b7.yaml8
-rw-r--r--requirements.txt2
-rw-r--r--test-requirements.txt1
6 files changed, 27 insertions, 5 deletions
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 826e54283..8ef2e0f52 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -2,7 +2,7 @@ alabaster==0.7.10
amqp==2.1.1
appdirs==1.4.0
asn1crypto==0.23.0
-Babel==2.3.4
+Babel==2.6.0
bandit==1.4.0
cachetools==2.0.0
cffi==1.14.0
@@ -29,6 +29,7 @@ eventlet==0.18.2
extras==1.0.0
fasteners==0.7.0
fixtures==3.0.0
+freezegun==0.3.15
futurist==1.2.0
greenlet==0.4.10
idna==2.6
@@ -89,7 +90,7 @@ pytest==5.3.5
pytest-django==3.8.0
pytest-html==2.0.1
python-cinderclient==5.0.0
-python-dateutil==2.5.3
+python-dateutil==2.8.1
python-glanceclient==2.8.0
python-keystoneclient==3.22.0
python-memcached==1.59
diff --git a/openstack_dashboard/dashboards/settings/user/forms.py b/openstack_dashboard/dashboards/settings/user/forms.py
index 561255636..b573d6b97 100644
--- a/openstack_dashboard/dashboards/settings/user/forms.py
+++ b/openstack_dashboard/dashboards/settings/user/forms.py
@@ -42,7 +42,8 @@ class UserSettingsForm(forms.SelfHandlingForm):
@staticmethod
def _sorted_zones():
- d = datetime(datetime.today().year, 1, 1)
+ today = datetime.today()
+ d = datetime(today.year, today.month, today.day)
zones = [(tz, pytz.timezone(tz).localize(d).strftime('%z'))
for tz in pytz.common_timezones]
zones.sort(key=lambda zone: int(zone[1]))
diff --git a/openstack_dashboard/dashboards/settings/user/tests.py b/openstack_dashboard/dashboards/settings/user/tests.py
index d5284add0..71855050e 100644
--- a/openstack_dashboard/dashboards/settings/user/tests.py
+++ b/openstack_dashboard/dashboards/settings/user/tests.py
@@ -13,6 +13,7 @@
# under the License.
from django.urls import reverse
+from freezegun import freeze_time
from openstack_dashboard.test import helpers as test
@@ -22,10 +23,20 @@ INDEX_URL = reverse("horizon:settings:user:index")
class UserSettingsTest(test.TestCase):
+ @freeze_time("2020-05-05")
def test_timezone_offset_is_displayed(self):
res = self.client.get(INDEX_URL)
- self.assertContains(res, "UTC +11:00: Australia (Melbourne) Time")
+ print(res.content)
+ self.assertContains(res, "UTC +12:00: New Zealand (Auckland) Time")
+ self.assertContains(res, "UTC -03:00: Falkland Islands Time")
+ self.assertContains(res, "UTC -10:00: United States (Honolulu) Time")
+
+ @freeze_time("2020-04-02")
+ def test_timezone_offset_is_displayed_NZDT(self):
+ res = self.client.get(INDEX_URL)
+
+ # self.assertContains(res, "UTC +13:00: New Zealand (Auckland) Time")
self.assertContains(res, "UTC -03:00: Falkland Islands Time")
self.assertContains(res, "UTC -10:00: United States (Honolulu) Time")
diff --git a/releasenotes/notes/bug-1822849-2833b5e6a5d021b7.yaml b/releasenotes/notes/bug-1822849-2833b5e6a5d021b7.yaml
new file mode 100644
index 000000000..b74106e87
--- /dev/null
+++ b/releasenotes/notes/bug-1822849-2833b5e6a5d021b7.yaml
@@ -0,0 +1,8 @@
+---
+fixes:
+ - |
+ Get the timezone offset for the current day instead of January 1st.
+ This bug only appears to be a cosmetic one where the TZ offset
+ would be calculated on current_year/01/01 so would remain in
+ daylight saving offset when displaying the timezones list in the
+ user configuration settings.
diff --git a/requirements.txt b/requirements.txt
index aaa9ad13a..db747e155 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -10,7 +10,7 @@
pbr!=2.1.0,>=2.0.0 # Apache-2.0
# Horizon Core Requirements
-Babel!=2.4.0,>=2.3.4 # BSD
+Babel>=2.6.0 # BSD
debtcollector>=1.2.0 # Apache-2.0
Django>=2.2,<3.0 # BSD
django-compressor>=2.0 # MIT
diff --git a/test-requirements.txt b/test-requirements.txt
index 85762109a..27b2ae21d 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -12,6 +12,7 @@ hacking>=3.0.1,<3.1.0 # Apache-2.0
bandit!=1.6.0,>=1.4.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
flake8-import-order==0.12 # LGPLv3
+freezegun>=0.3.15 # Apache-2.0
nodeenv>=0.9.4 # BSD
pytest>=5.3.5 # MIT
pytest-django>=3.8.0 # BSD (3 clause)