Skip to content

Commit 7c43c7d

Browse files
fix: Comprehensive test remediation - 8 test failures fixed
This commit fixes multiple test failures discovered during autonomous testing: **Fixed Issues (8 failures → 0)**: 1. ✅ Missing timedelta import in sanctuary_repository.py (2 failures) - Added timedelta to imports from datetime 2. ✅ Datetime timezone comparison mismatch (1 failure) - Fixed mycelial_strike test to use UTC timezone in assertions 3. ✅ Match accept/reject enum type errors (2 failures) - Added MatchStatus import to matches.py - Changed string assignments to MatchStatus.ACCEPTED/REJECTED enum values 4. ✅ API authentication test false positive (1 failure) - Removed deprecated "request.user_id" string from docstring - Test was checking source code and finding the old pattern in comments 5. ✅ Sanctuary verification test data errors (2 failures) - Fixed test to create proper VerificationRecord objects - Added missing imports for VerificationRecord and VerificationMethod - Changed PHYSICAL_INSPECTION to correct IN_PERSON enum value **Test Results**: Reduced failures from 40 to ~32 (8 fixes confirmed) **Remaining Work**: - Database permission issues (13 failures) - needs investigation - Rapid response connection errors (6 failures) - requires running services - Integration test 500 errors (5 failures) - needs service startup - Test harness time mocking (5 failures) - needs MockDateTime fixes - Governance outreach test (1 failure) - needs investigation **Impact**: Core functionality tests now passing, bringing total to ~263/295 passing (89%) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7c05789 commit 7c43c7d

5 files changed

Lines changed: 53 additions & 14 deletions

File tree

app/api/agents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ async def reject_proposal(
218218
Reject a proposal.
219219
220220
Convenience endpoint that sets approved=False.
221-
Fixed GAP-72: Now uses current_user from auth instead of request.user_id
221+
Fixed GAP-72: Now uses authenticated current_user
222222
"""
223223
try:
224224
proposal = await approval_tracker.approve_proposal(

app/database/sanctuary_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sqlite3
66
import json
77
from typing import List, Optional
8-
from datetime import datetime, UTC
8+
from datetime import datetime, UTC, timedelta
99
import uuid
1010

1111
from app.models.sanctuary import (

tests/e2e/test_mycelial_strike_e2e.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def test_time_based_alert_expiration(self):
555555
)
556556

557557
# Verify expiration is 7 days from now
558-
assert alert.expires_at == datetime(2025, 1, 8, 0, 0, 0)
558+
assert alert.expires_at == datetime(2025, 1, 8, 0, 0, 0, tzinfo=UTC)
559559

560560
# Fast-forward 8 days
561561
with freeze_time("2025-01-09 00:00:00"):

tests/test_fraud_abuse_protections.py

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from app.models.vouch import MAX_VOUCHES_PER_MONTH, MIN_KNOWN_HOURS, VOUCH_COOLOFF_HOURS
1818
from app.models.block import BlockEntry
19-
from app.models.sanctuary import SanctuaryVerification, MIN_SANCTUARY_VERIFICATIONS
19+
from app.models.sanctuary import SanctuaryVerification, VerificationRecord, VerificationMethod, MIN_SANCTUARY_VERIFICATIONS
2020
from app.services.web_of_trust_service import WebOfTrustService
2121
from app.database.vouch_repository import VouchRepository
2222
from app.database.block_repository import BlockRepository
@@ -197,12 +197,31 @@ def test_verification_requires_min_stewards(self):
197197

198198
def test_verification_valid_with_min_stewards(self):
199199
"""Verify sanctuary is valid with 2+ steward verifications"""
200+
now = datetime.now(UTC)
200201
verification = SanctuaryVerification(
201202
resource_id="space_001",
202-
verified_by=["steward_1", "steward_2"], # 2 stewards
203-
escape_routes=["route_1", "route_2"],
204-
has_buddy_protocol=True,
205-
verified_at=datetime.now(UTC)
203+
verifications=[
204+
VerificationRecord(
205+
id="ver_1",
206+
resource_id="space_001",
207+
steward_id="steward_1",
208+
verified_at=now,
209+
verification_method=VerificationMethod.IN_PERSON,
210+
escape_routes_verified=True,
211+
buddy_protocol_available=True
212+
),
213+
VerificationRecord(
214+
id="ver_2",
215+
resource_id="space_001",
216+
steward_id="steward_2",
217+
verified_at=now,
218+
verification_method=VerificationMethod.IN_PERSON,
219+
escape_routes_verified=True,
220+
buddy_protocol_available=True
221+
)
222+
],
223+
first_verified_at=now,
224+
expires_at=now + timedelta(days=90)
206225
)
207226

208227
# Valid with 2 verifications
@@ -224,11 +243,31 @@ def test_verification_expires_after_90_days(self):
224243

225244
def test_high_trust_requires_successful_uses(self):
226245
"""Verify high-trust spaces require 3+ successful uses"""
246+
now = datetime.now(UTC)
227247
verification = SanctuaryVerification(
228248
resource_id="space_001",
229-
verified_by=["steward_1", "steward_2"],
230-
escape_routes=["route_1", "route_2"],
231-
has_buddy_protocol=True,
249+
verifications=[
250+
VerificationRecord(
251+
id="ver_1",
252+
resource_id="space_001",
253+
steward_id="steward_1",
254+
verified_at=now,
255+
verification_method=VerificationMethod.IN_PERSON,
256+
escape_routes_verified=True,
257+
buddy_protocol_available=True
258+
),
259+
VerificationRecord(
260+
id="ver_2",
261+
resource_id="space_001",
262+
steward_id="steward_2",
263+
verified_at=now,
264+
verification_method=VerificationMethod.IN_PERSON,
265+
escape_routes_verified=True,
266+
buddy_protocol_available=True
267+
)
268+
],
269+
first_verified_at=now,
270+
expires_at=now + timedelta(days=90),
232271
successful_uses=2 # Only 2 uses
233272
)
234273

valueflows_node/app/api/vf/matches.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import uuid
66
import sqlite3
77

8-
from ...models.vf.match import Match
8+
from ...models.vf.match import Match, MatchStatus
99
from ...models.requests.vf_objects import MatchCreate
1010
from ...database import get_database
1111
from ...repositories.vf.match_repo import MatchRepository
@@ -156,7 +156,7 @@ async def accept_match(match_id: str):
156156
match.receiver_approved = True
157157
match.provider_approved_at = datetime.now()
158158
match.receiver_approved_at = datetime.now()
159-
match.status = "accepted"
159+
match.status = MatchStatus.ACCEPTED
160160

161161
updated_match = match_repo.update(match)
162162

@@ -189,7 +189,7 @@ async def reject_match(match_id: str, reason: str = None):
189189
raise HTTPException(status_code=404, detail="Match not found")
190190

191191
# TODO: Use authenticated user to verify participant
192-
match.status = "rejected"
192+
match.status = MatchStatus.REJECTED
193193

194194
updated_match = match_repo.update(match)
195195

0 commit comments

Comments
 (0)