activity-core/tests/test_repo_scoping_context_resolver.py
tegwick e4d6222d22
All checks were successful
CI Smoke / host-smoke (push) Successful in 2s
CI Smoke / container-smoke (push) Successful in 21s
Build and Publish Container Image / build-and-push (push) Successful in 33s
fix(context): use repo-scoping /scope/context endpoint
Cherry-picked from stale branch codex/wp-0012-scope-context (9709692).
main was still calling the old /repos/{slug}/scope path; repo-scoping now
serves GET /repos/{slug}/scope/context (web_api/app.py:1449). Includes the
resolver test and consistent workplan-doc updates. Test: 2 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 23:19:50 +02:00

66 lines
1.7 KiB
Python

from activity_core.context_resolvers import repo_scoping
class Response:
def __init__(self, body):
self.body = body
def raise_for_status(self):
return None
def json(self):
return self.body
def test_repo_scoping_context_resolver_calls_scope_context_endpoint(monkeypatch):
calls = []
body = {
"repo_slug": "repo-scoping",
"capabilities": ["Generate SCOPE.md"],
"tags": ["api", "scope"],
"scope_md_exists": True,
"scope_summary": "Maps repositories into reviewable context.",
}
def fake_get(url, timeout):
calls.append((url, timeout))
return Response(body)
repo_scoping._CACHE.clear()
monkeypatch.setattr(repo_scoping, "_REPO_SCOPING_URL", "http://repo-scoping.local/")
monkeypatch.setattr(repo_scoping.httpx, "get", fake_get)
resolver = repo_scoping.RepoScopingContextResolver()
result = resolver.resolve(
"repo_profile",
None,
{"repo_slug": "repo-scoping"},
)
assert result == body
assert calls == [
(
"http://repo-scoping.local/repos/repo-scoping/scope/context",
10.0,
)
]
cached = resolver.resolve(
"repo_profile",
None,
{"repo_slug": "repo-scoping"},
)
assert cached == body
assert len(calls) == 1
def test_repo_scoping_context_resolver_ignores_unknown_queries(monkeypatch):
repo_scoping._CACHE.clear()
monkeypatch.setattr(
repo_scoping.httpx,
"get",
lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("unexpected HTTP")),
)
assert repo_scoping.RepoScopingContextResolver().resolve("unknown", None, {}) == {}