David Hill f60220329a 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
2021-03-18 08:29:07 +09:00

56 lines
2.1 KiB
Python

# Copyright 2013 Red Hat, 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 django.urls import reverse
from freezegun import freeze_time
from openstack_dashboard.test import helpers as test
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)
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")
def test_display_language(self):
# Add an unknown language to LANGUAGES list
with self.modify_settings(
# NOTE: modify_settings take a list of values to append.
# We add a single entry but it is a tuple,
# so we need to wrap it as a list.
LANGUAGES={'append': [('unknown', 'Unknown Language')]}):
res = self.client.get(INDEX_URL)
# Known language
self.assertContains(res, 'English')
# Unknown language
self.assertContains(res, 'Unknown Language')