From 0ffb363e8718c5e48b8a0ef3707a09dcf0765610 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:53:33 -0500 Subject: [PATCH] test(fix): Allow missing extension.json file in non-extension repositories --- tests/test_json.py | 6 ++++-- tests/test_readme.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_json.py b/tests/test_json.py index 38614a7..209e778 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -74,8 +74,10 @@ } -def read_metadata(): +def read_metadata(allow_missing=False): path = os.path.join(cwd, 'extension.json') + if allow_missing and not os.path.isfile(path): + return {} with open(path) as f: return json.load(f) @@ -96,7 +98,7 @@ def read_metadata(): # Extensions that depend on those extensions. or ( 'https://raw.githubusercontent.com/open-contracting-extensions/ocds_lots_extension/master/extension.json' - in read_metadata().get('testDependencies', []) + in read_metadata(allow_missing=True).get('testDependencies', []) ) ) diff --git a/tests/test_readme.py b/tests/test_readme.py index 6498bdb..6176de6 100644 --- a/tests/test_readme.py +++ b/tests/test_readme.py @@ -17,8 +17,10 @@ from ocdskit.schema import get_schema_fields -def read_metadata(): +def read_metadata(allow_missing=False): path = os.path.join(cwd, 'extension.json') + if allow_missing and not os.path.isfile(path): + return {} with open(path) as f: return json.load(f) @@ -37,7 +39,7 @@ def read_metadata(): # Extensions that depend on those extensions. or ( 'https://raw.githubusercontent.com/open-contracting-extensions/ocds_lots_extension/master/extension.json' - in read_metadata().get('testDependencies', []) + in read_metadata(allow_missing=True).get('testDependencies', []) ) )