From dfcc264abac365291b2c62d9b15e1e6cfaedcb7e Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 20 Apr 2026 12:45:47 -0700 Subject: [PATCH] test: use db.add_contact helper in integration test fixture Replace raw sqlite3 INSERT in test_draft_without_llm_returns_402 with add_contact() so the fixture stays in sync with schema changes automatically. --- tests/test_messaging_integration.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_messaging_integration.py b/tests/test_messaging_integration.py index 94eaf48..fc4dd19 100644 --- a/tests/test_messaging_integration.py +++ b/tests/test_messaging_integration.py @@ -144,18 +144,18 @@ def test_builtin_template_delete_returns_403(client): def test_draft_without_llm_returns_402(fresh_db, monkeypatch): """POST /api/contacts/{id}/draft-reply with free tier + no LLM configured returns 402.""" - import sqlite3 import dev_api + from scripts.db import add_contact - # Insert a job_contacts row so the contact_id exists - con = sqlite3.connect(fresh_db) - con.execute( - "INSERT INTO job_contacts (job_id, direction, subject, from_addr, body) " - "VALUES (NULL, 'inbound', 'Test subject', 'hr@example.com', 'We would like to schedule...')" + # Insert a job_contacts row via the db helper so schema changes stay in sync + contact_id = add_contact( + fresh_db, + job_id=None, + direction="inbound", + subject="Test subject", + from_addr="hr@example.com", + body="We would like to schedule...", ) - con.commit() - contact_id = con.execute("SELECT last_insert_rowid()").fetchone()[0] - con.close() # Ensure has_configured_llm returns False at both import locations monkeypatch.setattr("app.wizard.tiers.has_configured_llm", lambda *a, **kw: False)