@@ -32,3 +32,32 @@ def test_validate_language_valid(name: str, value: Iterable[str] | str):
3232def test_validate_language_invalid (name : str , value : Iterable [str ] | str ):
3333 with pytest .raises (ValueError , match = re .escape ("is not ISO-639-3" )):
3434 metadata .validate_language (name , value )
35+
36+
37+ @pytest .mark .parametrize (
38+ "tags, is_valid" ,
39+ [
40+ pytest .param ("" , True , id = "empty_string" ),
41+ pytest .param ("tag1" , True , id = "empty_string" ),
42+ pytest .param ("taaaag1" , True , id = "many_letters" ),
43+ pytest .param ("tag1;tag2" , True , id = "semi_colon_distinct_1" ),
44+ pytest .param ("tag2;tag2" , False , id = "semi_colon_identical" ),
45+ pytest .param ("tag,1;tug,1" , True , id = "semi_colon_distinct_2" ),
46+ pytest .param (
47+ "tag1,tag2" , True , id = "comma"
48+ ), # we cannot say that this ought to be a tags separator
49+ pytest .param ({"tag1" }, True , id = "one_tag_in_set" ),
50+ pytest .param ({"tag1" , "tag2" }, True , id = "two_tags_in_set" ),
51+ pytest .param (1 , False , id = "one_int" ),
52+ pytest .param (None , False , id = "none_value" ),
53+ pytest .param (["tag1" , "tag2" ], True , id = "two_distinct" ),
54+ pytest .param (["tag1" , "tag1" ], False , id = "two_identical" ),
55+ pytest .param (["tag1" , 1 ], False , id = "int_in_list" ),
56+ ],
57+ )
58+ def test_validate_tags (tags , is_valid ):
59+ if is_valid :
60+ metadata .validate_tags ("Tags" , tags )
61+ else :
62+ with pytest .raises (ValueError ):
63+ metadata .validate_tags ("Tags" , tags )
0 commit comments