Skip to content

Commit d3cd892

Browse files
committed
Skip schema test if git repo is not available
1 parent 4798fa9 commit d3cd892

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

tests/unit_tests/service/test_openapi.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919

2020

2121
@pytest.fixture
22-
def reference_schema() -> Mapping[str, Any]:
23-
repo = git.Repo(TOP)
24-
relative_path_to_schema = DOCS_SCHEMA_LOCATION.relative_to(TOP)
25-
raw_yaml = repo.git.show(f"{MAIN}:{relative_path_to_schema}")
26-
return yaml.safe_load(raw_yaml)
22+
def reference_schema() -> Mapping[str, Any] | None:
23+
try:
24+
repo = git.Repo(TOP)
25+
relative_path_to_schema = DOCS_SCHEMA_LOCATION.relative_to(TOP)
26+
raw_yaml = repo.git.show(f"{MAIN}:{relative_path_to_schema}")
27+
return yaml.safe_load(raw_yaml)
28+
except git.exc.GitCommandError:
29+
return None
2730

2831

2932
@mock.patch("blueapi.service.openapi.get_app")
@@ -77,7 +80,10 @@ def test_schema_updated() -> None:
7780
reason="If the schema file does not exist, the test is being run"
7881
" with a non-editable install",
7982
)
80-
def test_schema_version_bump_required(reference_schema: Mapping[str, Any]) -> None:
83+
def test_schema_version_bump_required(reference_schema: Mapping[str, Any] | None):
84+
if reference_schema is None:
85+
pytest.skip("The reference schema is not available")
86+
return
8187
current_version = _get_version(generate_schema(), "schema in working tree")
8288
main_version = _get_version(reference_schema, "schema in main")
8389
if reference_schema != generate_schema():

0 commit comments

Comments
 (0)