Skip to content

Commit

Permalink
add filename construct validation (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjw24 authored Dec 15, 2024
1 parent 9c8aafd commit 474b7d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ci/src/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def plugin_reader() -> P:
return manifests

def get_plugin_files() -> list[str]:
return [os.path.join(plugin_dir, file) for file in os.listdir(plugin_dir)]
return [os.path.join(plugin_dir, filename) for filename in get_plugin_filenames()]

def get_plugin_filenames() -> list[str]:
return [file for file in os.listdir(plugin_dir)]

def etag_reader() -> ETagsType:
with open(etag_file, "r", encoding="utf-8") as f:
Expand Down
9 changes: 8 additions & 1 deletion ci/src/validator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*-coding: utf-8 -*-
from _utils import clean, id_name, language_list, language_name, plugin_reader, check_url, icon_path, get_plugin_files
from _utils import clean, id_name, language_list, language_name, plugin_reader, check_url, icon_path, get_plugin_files, get_plugin_filenames

plugin_infos = plugin_reader()

Expand Down Expand Up @@ -28,3 +28,10 @@ def test_file_type_json():
incorrect_ext_files = [file for file in get_plugin_files() if not file.endswith(".json")]

assert len(incorrect_ext_files) == 0, f"Expected the following file to be of .json extension: {incorrect_ext_files}"

def test_file_name_construct():
filenames = get_plugin_filenames()
for info in plugin_infos:
assert (
f"{info['Name']}-{info['ID']}.json" in filenames
), 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"

0 comments on commit 474b7d2

Please sign in to comment.