mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-14 18:52:47 +03:00
* Migrate to fastapi lifespan for startup events The `on_event` style decorator is deprecated https://fastapi.tiangolo.com/advanced/events/ * Migrate to pydantic TypeAdapter https://pydantic.dev/docs/validation/2.12/get-started/migration/#introduction-of-typeadapter * Replace pytz with native tz-aware objects and zoneinfo library Supported from Python 3.9, see https://peps.python.org/pep-0615/. Also https://blog.ganssle.io/articles/2019/11/utcnow.html. Also provide tzdata as new dependency to supplement systems without local tzdata information. * Provide lookup for normalized timezone names This provides a helper to look up the correct timezone name independent of the casing of the given timezone name. * Test timezone naming normalization and error handling
21 lines
619 B
Python
21 lines
619 B
Python
import unittest
|
|
|
|
from frigate.util.time import get_normalized_tz_name
|
|
|
|
|
|
class TestGetNormalizedTzName(unittest.TestCase):
|
|
def test_valid(self):
|
|
cases = [
|
|
("utc", "UTC"),
|
|
("america/new_york", "America/New_York"),
|
|
("us/eastern", "US/Eastern"),
|
|
]
|
|
|
|
for tz_name, expected in cases:
|
|
with self.subTest(tz_name=tz_name):
|
|
self.assertEqual(get_normalized_tz_name(tz_name), expected)
|
|
|
|
def test_invalid(self):
|
|
with self.assertRaisesRegex(ValueError, r"Unknown timezone: foo/bar"):
|
|
get_normalized_tz_name("foo/bar")
|