15
15
16
16
17
17
@pytest .mark .asyncio
18
- async def test_parse_invalid_time (caplog : pytest .LogCaptureFixture ) -> None :
18
+ async def test_parse_invalid_dt (caplog : pytest .LogCaptureFixture ) -> None :
19
19
device = ONVIFCamera ("127.0.0.1" , 80 , "user" , "pass" , wsdl_dir = _WSDL_PATH )
20
20
device .xaddrs = {
21
21
"http://www.onvif.org/ver10/events/wsdl" : "http://192.168.210.102:6688/onvif/event_service"
@@ -40,6 +40,31 @@ async def test_parse_invalid_time(caplog: pytest.LogCaptureFixture) -> None:
40
40
assert "ValueError" not in caplog .text
41
41
42
42
43
+ def test_parse_invalid_datetime () -> None :
44
+ with pytest .raises (ValueError , match = "Invalid character while parsing year" ):
45
+ FastDateTime ().pythonvalue ("aaaa-aa-aaTaa:aa:aaZ" )
46
+
47
+
48
+ def test_parse_invalid_time () -> None :
49
+ with pytest .raises (ValueError , match = "Unrecognised ISO 8601 time format" ):
50
+ ForgivingTime ().pythonvalue ("aa:aa:aa" )
51
+
52
+
53
+ def test_fix_datetime_missing_time () -> None :
54
+ assert FastDateTime ().pythonvalue ("2024-08-17" ) == datetime .datetime (
55
+ 2024 , 8 , 17 , 0 , 0 , 0
56
+ )
57
+
58
+
59
+ def test_fix_datetime_missing_t () -> None :
60
+ assert FastDateTime ().pythonvalue ("2024-08-17 00:61:16Z" ) == datetime .datetime (
61
+ 2024 , 8 , 17 , 1 , 1 , 16 , tzinfo = datetime .timezone .utc
62
+ )
63
+ assert FastDateTime ().pythonvalue ("2024-08-17 00:61:16" ) == datetime .datetime (
64
+ 2024 , 8 , 17 , 1 , 1 , 16
65
+ )
66
+
67
+
43
68
def test_fix_datetime_overflow () -> None :
44
69
assert FastDateTime ().pythonvalue ("2024-08-17T00:61:16Z" ) == datetime .datetime (
45
70
2024 , 8 , 17 , 1 , 1 , 16 , tzinfo = datetime .timezone .utc
0 commit comments