generated from coulomb/repo-seed
fix: distinguish consistency API lookup failures
This commit is contained in:
@@ -379,6 +379,43 @@ class TestRenderText:
|
||||
assert "C-08" not in text
|
||||
|
||||
|
||||
class TestRepoLookupFailures:
|
||||
def test_check_repo_reports_api_error_distinct_from_missing_repo(self, monkeypatch):
|
||||
def fake_get(_api_base, _path, params=None, *, return_error=False):
|
||||
assert params is None
|
||||
return {"_error": "Connection refused"} if return_error else None
|
||||
|
||||
monkeypatch.setattr("consistency_check._api_get", fake_get)
|
||||
|
||||
report = check_repo("http://127.0.0.1:8000", "state-hub")
|
||||
|
||||
assert report.repo_path == "(unknown)"
|
||||
assert len(report.failures) == 1
|
||||
assert report.failures[0].check_id == "C-00"
|
||||
assert "Could not query State Hub API" in report.failures[0].message
|
||||
assert "not found in state-hub DB" not in report.failures[0].message
|
||||
|
||||
def test_fix_repo_does_not_push_when_repo_lookup_failed(self, monkeypatch):
|
||||
pushed_paths = []
|
||||
|
||||
def fake_get(_api_base, _path, params=None, *, return_error=False):
|
||||
assert params is None
|
||||
return {"_error": "Connection refused"} if return_error else None
|
||||
|
||||
def fake_push(repo_path):
|
||||
pushed_paths.append(repo_path)
|
||||
return True, "pushed"
|
||||
|
||||
monkeypatch.setattr("consistency_check._api_get", fake_get)
|
||||
monkeypatch.setattr("consistency_check._git_push", fake_push)
|
||||
|
||||
report = fix_repo("http://127.0.0.1:8000", "state-hub")
|
||||
|
||||
assert report.failures[0].check_id == "C-00"
|
||||
assert pushed_paths == []
|
||||
assert report.fixes_applied == []
|
||||
|
||||
|
||||
class TestRenormalizationGuide:
|
||||
def test_registry_contains_c23_rule(self):
|
||||
rule = next(rule for rule in RENORMALIZATION_RULES if rule.check_id == "C-23")
|
||||
@@ -809,7 +846,7 @@ class TestLifecycleRenormalization:
|
||||
"description": None,
|
||||
}
|
||||
|
||||
def fake_get(_api_base, path, params=None):
|
||||
def fake_get(_api_base, path, params=None, **_kwargs):
|
||||
if path == "/repos/state-hub":
|
||||
import socket
|
||||
|
||||
|
||||
Reference in New Issue
Block a user