Files
rag-technical-docs-assistant/tests/support/database_rows.py
amirhosein mazaheri baf58da562 feat(ingestion): add Phase 1 database and application foundation
Add the scoped PostgreSQL/pgvector schema, independent ingestion settings and ports, embedding profile checks, and trusted administrator bootstrap.

Include repository contracts and guidance, organized provider-free and PostgreSQL tests, deployment setup, and byte-preserving migration attributes.

Validation: 163 tests passed; all 48 PostgreSQL cases passed with pgvector Python 0.5.0 and 0.3.6. No production schema or historical metadata was changed.
2026-10-05 16:38:28 +03:30

30 lines
1.3 KiB
Python

"""Shared database seed and rejection helpers; no test imports."""
from uuid import uuid4
import pytest
from sqlalchemy import text
from sqlalchemy.exc import IntegrityError, DataError
def seed(connection):
org, actor, document = uuid4(), uuid4(), uuid4()
connection.execute(text("INSERT INTO organizations(id,name) VALUES (:id,'test')"), {"id": org})
connection.execute(text("""
INSERT INTO users(id,organization_id,username,password_hash,role)
VALUES (:id,:org,:name,'test-only','admin')
"""), {"id": actor, "org": org, "name": str(actor)})
connection.execute(text("""
INSERT INTO documents(id,organization_id,uploaded_by,title,original_filename,
upload_request_id,upload_payload_hash,storage_key,file_sha256,mime_type,
size_bytes,processing_profile)
VALUES (:id,:org,:actor,'test','test.md',:request,:hash,:key,:hash,'text/markdown',
1,CAST(:profile AS jsonb))
"""), {"id": document, "org": org, "actor": actor, "request": uuid4(),
"hash": "a" * 64, "key": str(document), "profile": "{}"})
return org, actor, document
def rejected(engine, sql, params):
with pytest.raises((IntegrityError, DataError)):
with engine.begin() as connection:
connection.execute(text(sql), params)