mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-22 21:28:12 +02:00
refactor: standardize test database configuration across test files
This commit is contained in:
parent
f09b5b0ea4
commit
1068ea25a7
2 changed files with 8 additions and 9 deletions
|
|
@ -4,10 +4,14 @@ from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
os.environ.setdefault(
|
_DEFAULT_TEST_DB = (
|
||||||
"DATABASE_URL",
|
"postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense_test"
|
||||||
"postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense_test",
|
|
||||||
)
|
)
|
||||||
|
TEST_DATABASE_URL = os.environ.get("TEST_DATABASE_URL", _DEFAULT_TEST_DB)
|
||||||
|
|
||||||
|
# Force the app to use the test database regardless of any pre-existing
|
||||||
|
# DATABASE_URL in the environment (e.g. from .env or shell profile).
|
||||||
|
os.environ["DATABASE_URL"] = TEST_DATABASE_URL
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import os
|
|
||||||
import uuid
|
import uuid
|
||||||
from unittest.mock import AsyncMock, MagicMock
|
from unittest.mock import AsyncMock, MagicMock
|
||||||
|
|
||||||
|
|
@ -18,14 +17,10 @@ from app.db import (
|
||||||
User,
|
User,
|
||||||
)
|
)
|
||||||
from app.indexing_pipeline.connector_document import ConnectorDocument
|
from app.indexing_pipeline.connector_document import ConnectorDocument
|
||||||
|
from tests.conftest import TEST_DATABASE_URL
|
||||||
|
|
||||||
_EMBEDDING_DIM = app_config.embedding_model_instance.dimension
|
_EMBEDDING_DIM = app_config.embedding_model_instance.dimension
|
||||||
|
|
||||||
_DEFAULT_TEST_DB = (
|
|
||||||
"postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense_test"
|
|
||||||
)
|
|
||||||
TEST_DATABASE_URL = os.environ.get("TEST_DATABASE_URL", _DEFAULT_TEST_DB)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture(scope="session")
|
@pytest_asyncio.fixture(scope="session")
|
||||||
async def async_engine():
|
async def async_engine():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue