Some of the non canononical timezones are not present in Ubuntu Noble, it would be a better practice to only use canonical timezones in data and tests. Note that this is not a real fix for all cases since the database that ran on Ubuntu Jammy and are moved to an ubuntu Noble server will have the issue with timezones already in database. One of the possible fix would be to manage that during upgrades, but this isn't a verry flexible solution since upgrade are meant to manage chyange of version, not change of server. If an old 17.0 versions needs to be moved to a Noble server, this won't work. Another solution would be to install package like tzdata-legacy that may keep the old timezones but it is not the only think since TAI-10 are also in this package. This solution is not ideal because non canonical timezone will still be shown in the dropdown. We would need to filter them. A last solution would be to add the support for those old timezones by monkeypatching the lib. This way, only new timezones would be shown but non canonical one won't crash when used. This is not ideal either because we may need to keep this for a while. But in combination with the upgrade solution, it may work proprely. Part-of: odoo/odoo#160842
33 lines
1.7 KiB
Python
33 lines
1.7 KiB
Python
import pytz
|
|
|
|
from odoo.tests.common import TransactionCase
|
|
|
|
|
|
class TestTZ(TransactionCase):
|
|
|
|
def test_tz_legacy(self):
|
|
#See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
def assertTZEqual(tz1, tz2):
|
|
self.assertEqual(tz1._utcoffset, tz2._utcoffset)
|
|
self.assertEqual(tz1._transition_info, tz2._transition_info)
|
|
|
|
assertTZEqual(pytz.timezone('US/Eastern'), pytz.timezone('America/New_York'))
|
|
assertTZEqual(pytz.timezone('US/Central'), pytz.timezone('America/Chicago'))
|
|
assertTZEqual(pytz.timezone('US/Mountain'), pytz.timezone('America/Denver'))
|
|
assertTZEqual(pytz.timezone('US/Pacific'), pytz.timezone('America/Los_Angeles'))
|
|
assertTZEqual(pytz.timezone('US/Alaska'), pytz.timezone('America/Anchorage'))
|
|
assertTZEqual(pytz.timezone('US/Hawaii'), pytz.timezone('Pacific/Honolulu'))
|
|
assertTZEqual(pytz.timezone('Canada/Atlantic'), pytz.timezone('America/Halifax'))
|
|
assertTZEqual(pytz.timezone('Canada/Pacific'), pytz.timezone('America/Vancouver'))
|
|
assertTZEqual(pytz.timezone('Mexico/BajaNorte'), pytz.timezone('America/Tijuana'))
|
|
assertTZEqual(pytz.timezone('Mexico/General'), pytz.timezone('America/Mexico_City'))
|
|
assertTZEqual(pytz.timezone('Brazil/East'), pytz.timezone('America/Sao_Paulo'))
|
|
# This one is not correct for a strange reason
|
|
#assertTZEqual(pytz.timezone('Pacific/Midway'), pytz.timezone('Pacific/Pago_Pago'))
|
|
|
|
def test_cannot_set_deprecated_timezone(self):
|
|
# this should be ok
|
|
self.env.user.tz = "America/New_York"
|
|
if "US/Eastern" not in pytz.all_timezones:
|
|
with self.assertRaises(ValueError):
|
|
self.env.user.tz = "US/Eastern" |