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.
32 lines
995 B
Python
32 lines
995 B
Python
"""PostgreSQL-only fixtures and marker; ordinary tests need no database."""
|
|
import os
|
|
from pathlib import Path
|
|
import pytest
|
|
from tests.support.postgres import disposable_database, validated_test_url
|
|
|
|
|
|
@pytest.fixture
|
|
def test_database_url(request):
|
|
url = os.environ.get("TEST_DATABASE_URL")
|
|
if not url:
|
|
message = "TEST_DATABASE_URL is required for PostgreSQL acceptance"
|
|
if request.config.getoption("--require-postgres"):
|
|
pytest.fail(message)
|
|
pytest.skip(message + "; skipped tests are not acceptance evidence")
|
|
try:
|
|
return validated_test_url(url)
|
|
except ValueError as exc:
|
|
pytest.fail(str(exc))
|
|
|
|
|
|
@pytest.fixture
|
|
def migrated_db(settings, test_database_url):
|
|
with disposable_database(test_database_url, settings) as database:
|
|
yield database
|
|
|
|
|
|
def pytest_collection_modifyitems(items):
|
|
for item in items:
|
|
if Path(__file__).parent in item.path.parents:
|
|
item.add_marker(pytest.mark.postgres)
|