From 987124f3a693be0ef9579ae16e00b958396554a2 Mon Sep 17 00:00:00 2001 From: Christopher Sellers <1@christophersellers.com> Date: Fri, 23 Oct 2026 14:07:26 -0700 Subject: [PATCH] test(ingestion): fix-forward email_ingest principal stub and sel409 admin DB env Signed-off-by: Christopher Sellers <1@christophersellers.com> --- .../ingestion/tests/test_email_ingest_service.py | 16 ++++++++-------- .../ingestion/tests/test_sel409_session_auth.py | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/services/ingestion/tests/test_email_ingest_service.py b/services/ingestion/tests/test_email_ingest_service.py index 492ef34f1..d9146ee6e 100644 --- a/services/ingestion/tests/test_email_ingest_service.py +++ b/services/ingestion/tests/test_email_ingest_service.py @@ -52,9 +52,7 @@ def test_prefers_original_recipient(self): assert _first_recipient(payload) == "preferred@tenant.co" def test_strips_original_recipient(self): - payload = PostmarkInboundPayload( - MessageID="m1", From="a@example.com", OriginalRecipient=" spaced@tenant.co " - ) + payload = PostmarkInboundPayload(MessageID="m1", From="a@example.com", OriginalRecipient=" spaced@tenant.co ") assert _first_recipient(payload) == "spaced@tenant.co" def test_blank_original_recipient_falls_through_to_tofull(self): @@ -67,9 +65,7 @@ def test_blank_original_recipient_falls_through_to_tofull(self): assert _first_recipient(payload) == "tofull@tenant.co" def test_falls_back_to_tofull_lowercase_key(self): - payload = PostmarkInboundPayload( - MessageID="m1", From="a@example.com", ToFull=[{"email": "lower@tenant.co"}] - ) + payload = PostmarkInboundPayload(MessageID="m1", From="a@example.com", ToFull=[{"email": "lower@tenant.co"}]) assert _first_recipient(payload) == "lower@tenant.co" def test_tofull_skips_blank_entries_and_uses_first_valid(self): @@ -527,7 +523,9 @@ async def test_real_ingest_csv_is_not_401d_by_the_api_key_presence_gate(self, mo import app.csv_templates as csv_templates_mod from app.webhook_models import IngestResponse - async def fake_ingest_events(payload, *, principal_tenant_id, x_regengine_api_key=None, source_file=None): + async def fake_ingest_events( + payload, *, principal_tenant_id, x_regengine_api_key=None, principal=None, source_file=None + ): if not x_regengine_api_key: raise HTTPException(status_code=401, detail="Invalid or missing API key") return IngestResponse(accepted=1, rejected=0, total=1, events=[]) @@ -780,7 +778,9 @@ async def test_unmapped_recipient_with_attachments_runs_no_ingestion_and_sets_no # touch CSV ingestion nor set tenant context, even when it carries # attachments. The claim row is still recorded as rejected for audit. monkeypatch.setattr(service_mod, "get_inbound_email_audit_by_message_id", lambda db, mid: None) - monkeypatch.setattr(service_mod.tenant_lookup, "lookup_tenant_by_inbound_address", lambda db, addr, sender: None) + monkeypatch.setattr( + service_mod.tenant_lookup, "lookup_tenant_by_inbound_address", lambda db, addr, sender: None + ) _stub_claim(monkeypatch, succeeds=True) monkeypatch.setattr(service_mod, "finalize_inbound_email_audit", lambda db, **kwargs: {"id": "1"}) diff --git a/services/ingestion/tests/test_sel409_session_auth.py b/services/ingestion/tests/test_sel409_session_auth.py index 54e3157ed..19582513e 100644 --- a/services/ingestion/tests/test_sel409_session_auth.py +++ b/services/ingestion/tests/test_sel409_session_auth.py @@ -15,6 +15,9 @@ def _request(path: str) -> Request: @pytest.mark.asyncio async def test_session_without_selected_rls_tenant_is_denied(monkeypatch): + monkeypatch.setenv("REGENGINE_ENV", "test") + monkeypatch.setenv("ADMIN_FALLBACK_SQLITE", "sqlite:///:memory:") + monkeypatch.delenv("ADMIN_DATABASE_URL", raising=False) from services.admin.app import auth_routes, database, dependencies async def verified_user(**_kwargs):