Skip to content

Commit baedcc7

Browse files
vvillait88claude
andcommitted
chore: replace fake reason codes in tests with real API codes
Tests used invented reason strings like \`not_kyc\`, \`score_too_low\`, \`sanctions_check_pending\` that don't exist in the API surface (the real codes are \`kyc_required\`, \`kyc_pending\`, \`kyc_failed\`, \`sanctions_flagged\`, \`age_insufficient\`, \`jurisdiction_restricted\`). Tests pass either way (the gate passes reasons through verbatim), but the fake strings propagate misinformation. Replace with real codes for documentation accuracy. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 096dff7 commit baedcc7

6 files changed

Lines changed: 14 additions & 14 deletions

File tree

tests/test_aiohttp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ async def handler(request: web.Request) -> web.Response:
7878
@pytest.mark.asyncio
7979
@respx.mock
8080
async def test_denies_untrusted_wallet(self):
81-
_mock_assess("deny", reasons=["not_kyc"])
81+
_mock_assess("deny", reasons=["kyc_required"])
8282
client = await _client(_make_app())
8383
async with client:
8484
resp = await client.get("/", headers={"X-Wallet-Address": "0xabc"})
8585
assert resp.status == 403
8686
data = await resp.json()
8787
assert data["error"]["code"] == "wallet_not_trusted"
88-
assert data["reasons"] == ["not_kyc"]
88+
assert data["reasons"] == ["kyc_required"]
8989

9090
@pytest.mark.asyncio
9191
async def test_missing_identity_returns_403(self):

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def test_full_compliance_deny_flow(self):
394394
"""Integration test: full middleware flow with compliance deny."""
395395
compliance_response = {
396396
"decision": "deny",
397-
"decision_reasons": ["kyc_required", "sanctions_check_pending"],
397+
"decision_reasons": ["kyc_required", "sanctions_flagged"],
398398
"score": {"value": 72, "grade": "C", "status": "scored"},
399399
"operator_verification": {
400400
"level": "none",
@@ -424,7 +424,7 @@ def test_full_compliance_deny_flow(self):
424424
assert result.allow is False
425425
assert result.decision == "deny"
426426
assert "kyc_required" in result.reasons
427-
assert "sanctions_check_pending" in result.reasons
427+
assert "sanctions_flagged" in result.reasons
428428
assert result.verify_url == "https://agentscore.sh/verify/xyz789"
429429
assert result.operator_verification is not None
430430
assert result.operator_verification.level == "none"

tests/test_django.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_allows_trusted_wallet(self) -> None:
6161

6262
def test_blocks_untrusted_wallet(self) -> None:
6363
mw = self._make_middleware()
64-
result = AssessResult(allow=False, decision="deny", reasons=["score_too_low"], raw={})
64+
result = AssessResult(allow=False, decision="deny", reasons=["kyc_required"], raw={})
6565
request = self.factory.get("/", HTTP_X_WALLET_ADDRESS="0xabc")
6666
with patch("agentscore_commerce.identity.django.GateClient.check", return_value=result):
6767
resp = mw(request)
@@ -178,7 +178,7 @@ def test_deny_includes_reasons_from_compliance(self) -> None:
178178
result = AssessResult(
179179
allow=False,
180180
decision="deny",
181-
reasons=["kyc_required", "sanctions_check_pending"],
181+
reasons=["kyc_required", "sanctions_flagged"],
182182
raw={
183183
"verify_url": "https://agentscore.sh/verify/abc123",
184184
"operator_verification": {"level": "none"},
@@ -191,7 +191,7 @@ def test_deny_includes_reasons_from_compliance(self) -> None:
191191
data = json.loads(resp.content)
192192
assert data["error"]["code"] == "wallet_not_trusted"
193193
assert "kyc_required" in data["reasons"]
194-
assert "sanctions_check_pending" in data["reasons"]
194+
assert "sanctions_flagged" in data["reasons"]
195195

196196
def test_allow_with_operator_verification_attaches_to_request(self) -> None:
197197
mw = self._make_middleware()

tests/test_fastapi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ def test_allows_trusted_wallet(self):
5757

5858
@respx.mock
5959
def test_denies_untrusted_wallet(self):
60-
_mock_assess("deny", reasons=["not_kyc"])
60+
_mock_assess("deny", reasons=["kyc_required"])
6161
gate = AgentScoreGate(api_key="ask_test")
6262
client = TestClient(_make_app(gate))
6363
resp = client.get("/", headers={"X-Wallet-Address": "0xabc"})
6464
assert resp.status_code == 403
6565
body = resp.json()
6666
# FastAPI wraps HTTPException detail in {"detail": {...}}.
6767
assert body["detail"]["error"]["code"] == "wallet_not_trusted"
68-
assert body["detail"]["reasons"] == ["not_kyc"]
68+
assert body["detail"]["reasons"] == ["kyc_required"]
6969

7070
def test_missing_identity_returns_403(self):
7171
gate = AgentScoreGate(api_key="ask_test")

tests/test_flask.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_get_assess_data_returns_none_outside_request(self) -> None:
6464

6565
def test_blocks_untrusted_wallet(self) -> None:
6666
app = _make_app()
67-
result = AssessResult(allow=False, decision="deny", reasons=["score_too_low"], raw={})
67+
result = AssessResult(allow=False, decision="deny", reasons=["kyc_required"], raw={})
6868
with patch("agentscore_commerce.identity.flask.GateClient.check", return_value=result):
6969
client = app.test_client()
7070
resp = client.get("/", headers={"x-wallet-address": "0xabc"})
@@ -176,7 +176,7 @@ def test_deny_includes_compliance_reasons(self) -> None:
176176
result = AssessResult(
177177
allow=False,
178178
decision="deny",
179-
reasons=["kyc_required", "sanctions_check_pending"],
179+
reasons=["kyc_required", "sanctions_flagged"],
180180
raw={
181181
"verify_url": "https://agentscore.sh/verify/abc123",
182182
"operator_verification": {"level": "none"},
@@ -189,7 +189,7 @@ def test_deny_includes_compliance_reasons(self) -> None:
189189
data = resp.get_json()
190190
assert data["error"]["code"] == "wallet_not_trusted"
191191
assert "kyc_required" in data["reasons"]
192-
assert "sanctions_check_pending" in data["reasons"]
192+
assert "sanctions_flagged" in data["reasons"]
193193

194194
def test_allow_with_operator_verification_attaches_to_g(self) -> None:
195195
app = _make_app()

tests/test_sanic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _allow_result() -> AssessResult:
2121

2222

2323
def _deny_result() -> AssessResult:
24-
return AssessResult(allow=False, decision="deny", reasons=["not_kyc"])
24+
return AssessResult(allow=False, decision="deny", reasons=["kyc_required"])
2525

2626

2727
def _make_app(name: str, **gate_kwargs) -> Sanic:
@@ -78,7 +78,7 @@ def test_denies_untrusted_wallet(self):
7878
_, resp = app.test_client.get("/", headers={"X-Wallet-Address": "0xabc"})
7979
assert resp.status == 403
8080
assert resp.json["error"]["code"] == "wallet_not_trusted"
81-
assert resp.json["reasons"] == ["not_kyc"]
81+
assert resp.json["reasons"] == ["kyc_required"]
8282

8383
def test_missing_identity_returns_403(self):
8484
app = _make_app("sanic_missing")

0 commit comments

Comments
 (0)