|
@@ -284,3 +284,20 @@ def test_parse_duration():
|
|
with pytest.raises(ValueError) as err:
|
|
with pytest.raises(ValueError) as err:
|
|
utils.parse_duration("Hello")
|
|
utils.parse_duration("Hello")
|
|
assert str(err.value) == f"The duration 'Hello' did not match the requested format"
|
|
assert str(err.value) == f"The duration 'Hello' did not match the requested format"
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def test_parse_datetime_no_microseconds():
|
|
|
|
+ dt = "2020-12-15T11:29:34Z"
|
|
|
|
+ result = utils.parse_datetime(dt)
|
|
|
|
+ assert result == datetime(2020, 12, 15, 11, 29, 34, tzinfo=timezone.utc)
|
|
|
|
+
|
|
|
|
+def test_parse_datetime_with_microseconds():
|
|
|
|
+ dt = "2020-12-15T11:29:34.123456Z"
|
|
|
|
+ result = utils.parse_datetime(dt)
|
|
|
|
+ assert result == datetime(2020, 12, 15, 11, 29, 34, 123456, tzinfo=timezone.utc)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def test_parse_datetime_with_milliseconds():
|
|
|
|
+ dt = "2020-12-15T11:29:34.123Z"
|
|
|
|
+ result = utils.parse_datetime(dt)
|
|
|
|
+ assert result == datetime(2020, 12, 15, 11, 29, 34, 123000, tzinfo=timezone.utc)
|