mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-08 18:34:24 -04:00
This changeset pulls in all of the notification_utils code directly into the admin and removes it as an external dependency. We are doing this to cut down on operational maintenance of the project and will begin removing parts of it no longer needed for the admin. Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
37 lines
972 B
Python
37 lines
972 B
Python
import dateutil
|
|
import pytest
|
|
|
|
from notifications_utils.timezones import utc_string_to_aware_gmt_datetime
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"input_value,expectation",
|
|
[
|
|
("foo", pytest.raises(dateutil.parser._parser.ParserError)),
|
|
(100, pytest.raises(TypeError)),
|
|
(True, pytest.raises(TypeError)),
|
|
(False, pytest.raises(TypeError)),
|
|
(None, pytest.raises(TypeError)),
|
|
],
|
|
)
|
|
def test_utc_string_to_aware_gmt_datetime_rejects_bad_input(input_value, expectation):
|
|
with expectation:
|
|
utc_string_to_aware_gmt_datetime(input_value)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"naive_time, expected_aware_hour",
|
|
[
|
|
("2000-12-1 20:01", "15:01"),
|
|
("2000-06-1 20:01", "16:01"),
|
|
],
|
|
)
|
|
def test_utc_string_to_aware_gmt_datetime_handles_summer_and_winter(
|
|
naive_time,
|
|
expected_aware_hour,
|
|
):
|
|
assert (
|
|
utc_string_to_aware_gmt_datetime(naive_time).strftime("%H:%M")
|
|
== expected_aware_hour
|
|
)
|