Exemplo n.º 1
0
    def fetch_timezone_coordinates(self, iana_name: str) -> Coordinates:
        try:
            coordinates: iana_tz_coord.Coordinates = iana_tz_coord.get_coordinates(iana_name)
        except LookupError:
            raise exceptions.InvalidIanaTimezoneError(f'{iana_name} is not a known iana timezone.')

        return Coordinates(**coordinates._asdict())
Exemplo n.º 2
0
 def test_raises_lookup_error_on_invalid_timezone(self) -> None:
     with pytest.raises(LookupError):
         get_coordinates('Aqua_Magna/Mata_Nui')
Exemplo n.º 3
0
 def test_can_ignore_special_iana_prefix(
         self, iana_tz_name_with_prefix: str) -> None:
     iana_tz_name_without_prefix = _remove_extra_iana_prefix(
         iana_tz_name_with_prefix)
     assert get_coordinates(iana_tz_name_with_prefix) == get_coordinates(
         iana_tz_name_without_prefix)
Exemplo n.º 4
0
 def test_returns_coordinates_for_america_montreal(self) -> None:
     coordinates = get_coordinates('America/Montreal')
     expected_coordinates = Coordinates(latitude=43.65,
                                        longitude=-79.38333333333334)
     assert coordinates == expected_coordinates
Exemplo n.º 5
0
 def test_returns_coordinates_for_america_new_york(self) -> None:
     coordinates = get_coordinates('America/New_York')
     expected_coordinates = Coordinates(latitude=40.714166666666664,
                                        longitude=-74.00638888888889)
     assert coordinates == expected_coordinates