diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-30 07:57:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-30 07:57:29 +0000 |
commit | a003430ded2dbfbfb48acd3c17f143cbafeee60a (patch) | |
tree | 9016b0b904b32c46542f48de704b3e536b90e1af /tests/tz/zoneinfo/test_reader.py | |
parent | Initial commit. (diff) | |
download | pendulum-a003430ded2dbfbfb48acd3c17f143cbafeee60a.tar.xz pendulum-a003430ded2dbfbfb48acd3c17f143cbafeee60a.zip |
Adding upstream version 2.1.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/tz/zoneinfo/test_reader.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/tz/zoneinfo/test_reader.py b/tests/tz/zoneinfo/test_reader.py new file mode 100644 index 0000000..a19ba9a --- /dev/null +++ b/tests/tz/zoneinfo/test_reader.py @@ -0,0 +1,46 @@ +import os + +import pytest + +from pendulum.tz.zoneinfo.exceptions import InvalidTimezone +from pendulum.tz.zoneinfo.exceptions import InvalidZoneinfoFile +from pendulum.tz.zoneinfo.reader import Reader +from pendulum.tz.zoneinfo.timezone import Timezone + + +def test_read_for_bad_timezone(): + reader = Reader() + with pytest.raises(InvalidTimezone): + reader.read_for("---NOT A TIMEZONE---") + + +def test_read_for_valid(): + reader = Reader() + + tz = reader.read_for("America/Toronto") + assert isinstance(tz, Timezone) + + +def test_read(): + reader = Reader() + local_path = os.path.join(os.path.split(__file__)[0], "..", "..") + tz_file = os.path.join(local_path, "fixtures", "tz", "Paris") + tz = reader.read(tz_file) + + assert len(tz.transitions) > 0 + + +def test_read_invalid(): + reader = Reader() + local_path = os.path.join(os.path.split(__file__)[0], "..") + tz_file = os.path.join(local_path, "fixtures", "tz", "NOT_A_TIMEZONE") + + with pytest.raises(InvalidZoneinfoFile): + reader.read(tz_file) + + +def test_set_transitions_for_no_transition_database_file(): + reader = Reader() + tz = reader.read_for("Etc/UTC") + + assert len(tz.transitions) == 1 |