@@ -448,6 +448,54 @@ def test_fail_on_invalid_key() -> None:
448448 default_metadata_dict (codecs = [{"name" : "bytes" , "unknown" : {}, "configuration" : {}}])
449449 )
450450
451+ # accepts invalid key with must_understand=false
452+ ArrayV3Metadata .from_dict (
453+ default_metadata_dict (
454+ codecs = [{"name" : "bytes" , "configuration" : {}, "unknown" : {"must_understand" : False }}]
455+ )
456+ )
457+
458+
459+ @pytest .mark .parametrize (
460+ "codecs" ,
461+ [
462+ [{"name" : "bytes" , "configuration" : {}}],
463+ [{"name" : "transpose" , "configuration" : {"order" : (0 ,)}}, "bytes" ],
464+ [
465+ "bytes" ,
466+ {
467+ "name" : "blosc" ,
468+ "configuration" : {
469+ "cname" : "lz4" ,
470+ "clevel" : 1 ,
471+ "shuffle" : "shuffle" ,
472+ "typesize" : 4 ,
473+ "blocksize" : 0 ,
474+ },
475+ },
476+ ],
477+ ["bytes" , {"name" : "gzip" , "configuration" : {"level" : 1 }}],
478+ ["bytes" , {"name" : "zstd" , "configuration" : {"level" : 1 }}],
479+ ["bytes" , {"name" : "crc32c" , "configuration" : {}}],
480+ [{"name" : "sharding_indexed" , "configuration" : {"chunk_shape" : (1 ,)}}],
481+ [{"name" : "vlen-utf8" , "configuration" : {}}],
482+ [{"name" : "vlen-bytes" , "configuration" : {}}],
483+ ],
484+ )
485+ def test_codecs_fail_on_invalid_key (codecs ) -> None :
486+ ArrayV3Metadata .from_dict (default_metadata_dict (codecs = codecs ))
487+
488+ for codec in codecs :
489+ if codec != "bytes" :
490+ codec ["configuration" ]["unknown" ] = "value"
491+ with pytest .raises (ValueError ):
492+ ArrayV3Metadata .from_dict (default_metadata_dict (codecs = codecs ))
493+ # accepts invalid key with must_understand=false
494+ for codec in codecs :
495+ if codec != "bytes" :
496+ codec ["configuration" ]["unknown" ] = {"must_understand" : False }
497+ ArrayV3Metadata .from_dict (default_metadata_dict (codecs = codecs ))
498+
451499
452500def test_specify_codecs_with_strings () -> None :
453501 expected = ArrayV3Metadata .from_dict (
0 commit comments