File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ def check_json_v2(data: object) -> TypeGuard[Crc32cJSON_V2]:
44
44
45
45
46
46
def check_json_v3 (data : object ) -> TypeGuard [Crc32cJSON_V3 ]:
47
+ if data == "crc32c" :
48
+ return True
47
49
return (
48
50
isinstance (data , Mapping )
49
51
and set (data .keys ()) in ({"name" , "configuration" }, {"name" })
Original file line number Diff line number Diff line change @@ -23,16 +23,24 @@ class BaseTestCodec:
23
23
"""
24
24
25
25
test_cls : type [Codec ]
26
- valid_json_v2 : ClassVar [tuple [CodecJSON_V2 , ...]]
27
- valid_json_v3 : ClassVar [tuple [CodecJSON_V3 , ...]]
28
-
29
- def test_from_json_roundtrip_v2 (self , valid_json_v2 : CodecJSON_V2 ) -> None :
26
+ valid_json_v2 : ClassVar [tuple [CodecJSON_V2 | object , ...]]
27
+ valid_json_v3 : ClassVar [tuple [CodecJSON_V3 | object , ...]]
28
+
29
+ def test_from_json_v2 (self , valid_json_v2 : CodecJSON_V2 ) -> None :
30
+ """
31
+ Test that the codec generated from valid JSON generates a JSON representation that generates
32
+ the same codec
33
+ """
30
34
codec = self .test_cls .from_json (valid_json_v2 )
31
- assert codec .to_json (zarr_format = 2 ) == valid_json_v2
35
+ assert codec .from_json ( codec . to_json (zarr_format = 2 )) == codec
32
36
33
- def test_from_json_roundtrip_v3 (self , valid_json_v3 : CodecJSON_V3 ) -> None :
37
+ def test_from_json_v3 (self , valid_json_v3 : CodecJSON_V3 ) -> None :
38
+ """
39
+ Test that the codec generated from valid JSON generates a JSON representation that generates
40
+ the same codec
41
+ """
34
42
codec = self .test_cls .from_json (valid_json_v3 )
35
- assert codec .to_json (zarr_format = 3 ) == valid_json_v3
43
+ assert codec .from_json ( codec . to_json (zarr_format = 3 )) == codec
36
44
37
45
38
46
def pytest_generate_tests (metafunc : Any ) -> None :
Original file line number Diff line number Diff line change 34
34
35
35
class TestCrc32cCodec (BaseTestCodec ):
36
36
test_cls = Crc32cCodec
37
- valid_json_v2 = ({"id" : "crc32c" },)
38
- valid_json_v3 = ({"name" : "crc32c" },)
37
+ valid_json_v2 = (
38
+ {"id" : "crc32c" },
39
+ pytest .param (
40
+ {"id" : "crc32c" , "location" : "start" },
41
+ marks = pytest .mark .xfail (reason = "start location not supported" ),
42
+ ),
43
+ {"id" : "crc32c" , "location" : "end" },
44
+ )
45
+ valid_json_v3 = ({"name" : "crc32c" }, "crc32c" )
39
46
40
47
41
48
class TestCrc32cCodecJSON :
You can’t perform that action at this time.
0 commit comments