@@ -1001,3 +1001,63 @@ class VendoredFieldModel(BaseModel):
10011001 # Validate the invalid vendored fields against the vendored patterns
10021002 with pytest .raises (ValidationError ):
10031003 VendoredFieldModel .model_validate (invalid_vendored_fields )
1004+
1005+
1006+ class TestOtherIdentifiers :
1007+ def test_not_specified (self , base_dandiset_metadata : dict [str , Any ]) -> None :
1008+ """
1009+ Test the case that `otherIdentifiers` is not specified
1010+ """
1011+ dandiset = Dandiset .model_validate (base_dandiset_metadata )
1012+ assert dandiset .otherIdentifiers == []
1013+
1014+ def test_empty_list (self , base_dandiset_metadata : dict [str , Any ]) -> None :
1015+ """
1016+ Test the case that `otherIdentifiers` is an empty list
1017+ """
1018+ base_dandiset_metadata ["otherIdentifiers" ] = []
1019+ dandiset = Dandiset .model_validate (base_dandiset_metadata )
1020+ assert dandiset .otherIdentifiers == []
1021+
1022+ @pytest .mark .parametrize (
1023+ "identifiers" ,
1024+ [
1025+ ["DANDI-SANDBOX:123456" ],
1026+ ["EMBER-DANDI:123456" ],
1027+ ["DANDI-SANDBOX:123456" , "EMBER-DANDI:123456" ],
1028+ ["A:123456" , "B:654321" ],
1029+ ],
1030+ )
1031+ def test_with_valid_identifiers (
1032+ self , identifiers : list [str ], base_dandiset_metadata : dict [str , Any ]
1033+ ) -> None :
1034+ """
1035+ Test the case that `otherIdentifiers` is set to a list of valid identifiers
1036+ """
1037+ base_dandiset_metadata ["otherIdentifiers" ] = identifiers
1038+ dandiset = Dandiset .model_validate (base_dandiset_metadata )
1039+ assert dandiset .otherIdentifiers == identifiers
1040+
1041+ @pytest .mark .parametrize (
1042+ "identifiers" ,
1043+ [
1044+ # List of invalid identifiers
1045+ ["-A:123456" ],
1046+ ["DANDI-SANDBOX:12345" ],
1047+ ["DANDI-SANDBOX:123456" , "EMBER-DANDI123456" ],
1048+ [42 ],
1049+ # Value that is not a list
1050+ "DANDI-SANDBOX:123456" ,
1051+ 42 ,
1052+ ],
1053+ )
1054+ def test_with_invalid_identifiers (
1055+ self , identifiers : Any , base_dandiset_metadata : dict [str , Any ]
1056+ ) -> None :
1057+ """
1058+ Test the case that `otherIdentifiers` is set to a list of invalid identifiers
1059+ or a value that is not a list
1060+ """
1061+ base_dandiset_metadata ["otherIdentifiers" ] = identifiers
1062+ with pytest .raises (ValidationError ):
1063+ Dandiset .model_validate (base_dandiset_metadata )
0 commit comments