From 0d4e353089829dbcf3f79a7d66454089f8fc508f Mon Sep 17 00:00:00 2001 From: snake-biscuits <36507175+snake-biscuits@users.noreply.github.com> Date: Sat, 4 Mar 2023 03:47:58 +0000 Subject: [PATCH] (#5) testing `pilot/*.json` filenames match definitions --- tests/test_json.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_json.py b/tests/test_json.py index 722ef68..9b50dea 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -60,6 +60,9 @@ def valid_conversion(value: str, func, count: int) -> bool: def test_entity(json_filename: str): with open(json_filename) as json_file: entity = json.load(json_file) + filename_ext = os.path.basename(json_filename) + filename = os.path.splitext(filename_ext)[0] + assert filename == entity["Entity"], f"{entity['Entity']} defined in {filename_ext}" jsonschema.validate(entity, schema=entity_schema) # TODO: test choiceTypes are defined in either mrvn/*.xml or pilot/*/choiceTypes/*.json # TODO: verify any choiceType selections are valid @@ -69,8 +72,10 @@ def test_entity(json_filename: str): def test_choiceType(json_filename: str): with open(json_filename) as json_file: choiceType = json.load(json_file) + filename_ext = os.path.basename(json_filename) + filename = os.path.splitext(filename_ext)[0] + assert filename == choiceType["Name"], f"{choiceType['Name']} defined in {filename_ext}" jsonschema.validate(choiceType, schema=choiceType_schema) - # TODO: enforce filename matches blocks = json.load(open("blocks.json"))