11# -*-coding: utf-8 -*-
2- from _utils import clean , id_name , language_list , language_name , plugin_reader , check_url , icon_path , get_plugin_files , get_plugin_filenames
2+ import uuid
3+
4+ from _utils import (check_url , clean , get_file_plugins_json_info , get_plugin_file_paths , get_plugin_filenames ,
5+ icon_path , id_name , language_list , language_name , plugin_reader )
36
47plugin_infos = plugin_reader ()
58
@@ -25,7 +28,7 @@ def test_valid_icon_url():
2528 assert check_url (plugin [icon_path ]), msg
2629
2730def test_file_type_json ():
28- incorrect_ext_files = [file for file in get_plugin_files () if not file .endswith (".json" )]
31+ incorrect_ext_files = [file_path for file_path in get_plugin_file_paths () if not file_path .endswith (".json" )]
2932
3033 assert len (incorrect_ext_files ) == 0 , f"Expected the following file to be of .json extension: { incorrect_ext_files } "
3134
@@ -35,3 +38,20 @@ def test_file_name_construct():
3538 assert (
3639 f"{ info ['Name' ]} -{ info ['ID' ]} .json" in filenames
3740 ), f"Plugin { info ['Name' ]} with ID { info ['ID' ]} does not have the correct filename. Make sure it's name + ID, i.e. { info ['Name' ]} -{ info ['ID' ]} .json"
41+
42+ def test_submitted_plugin_id_is_valid_uuid ():
43+ plugins_json_ids = [item ["ID" ] for item in get_file_plugins_json_info ("ID" )]
44+ existing_plugin_file_ids = [info ["ID" ] for info in plugin_infos ]
45+
46+ for id in existing_plugin_file_ids :
47+ # plugins.json would not contain new submission's ID.
48+ if id in plugins_json_ids :
49+ continue
50+
51+ try :
52+ uuid .UUID (id , version = 4 )
53+ outcome = True
54+ except ValueError :
55+ outcome = False
56+
57+ assert outcome is True , f"The submission plugin ID { id } is not a valid v4 UUID"
0 commit comments