|
7 | 7 | from uuid import uuid4 |
8 | 8 |
|
9 | 9 | import pytest |
10 | | -from duckdb import ColumnExpression, ConstantExpression, DuckDBPyConnection |
| 10 | +from duckdb import ColumnExpression, ConstantExpression, DuckDBPyConnection, connect |
11 | 11 |
|
12 | 12 | from dve.core_engine.backends.implementations.duckdb.auditing import DDBAuditingManager |
13 | 13 | from dve.core_engine.models import ProcessingStatusRecord, SubmissionInfo, SubmissionStatisticsRecord |
14 | 14 | from dve.pipeline.utils import SubmissionStatus |
15 | 15 |
|
16 | | -from .....fixtures import temp_ddb_conn # pylint: disable=unused-import |
17 | | - |
18 | 16 |
|
19 | 17 | @pytest.fixture(scope="function") |
20 | | -def ddb_audit_manager(temp_ddb_conn) -> Iterator[DDBAuditingManager]: |
21 | | - db_file: Path |
22 | | - conn: DuckDBPyConnection |
23 | | - db_file, conn = temp_ddb_conn |
24 | | - yield DDBAuditingManager(database_uri=db_file.as_uri(), connection=conn) |
| 18 | +def ddb_audit_manager() -> Iterator[DDBAuditingManager]: |
| 19 | + db = f"dve_{uuid4().hex}" |
| 20 | + with tempfile.TemporaryDirectory(prefix="ddb_audit_testing") as tmp: |
| 21 | + db_file = Path(tmp, db + ".duckdb") |
| 22 | + conn = connect(database=db_file, read_only=False) |
| 23 | + |
| 24 | + yield DDBAuditingManager(database_uri=db_file.as_uri(), connection=conn) |
25 | 25 |
|
26 | 26 |
|
27 | 27 | @pytest.fixture(scope="function") |
28 | | -def ddb_audit_manager_threaded(temp_ddb_conn) -> Iterator[DDBAuditingManager]: |
29 | | - db_file: Path |
30 | | - conn: DuckDBPyConnection |
31 | | - db_file, conn = temp_ddb_conn |
32 | | - with ThreadPoolExecutor(1) as pool: |
33 | | - yield DDBAuditingManager(database_uri=db_file.as_uri(), pool=pool, connection=conn) |
| 28 | +def ddb_audit_manager_threaded() -> Iterator[DDBAuditingManager]: |
| 29 | + db = f"dve_{uuid4().hex}" |
| 30 | + with tempfile.TemporaryDirectory(prefix="ddb_audit_testing") as tmp: |
| 31 | + db_file = Path(tmp, db + ".duckdb") |
| 32 | + conn = connect(database=db_file, read_only=False) |
| 33 | + |
| 34 | + with ThreadPoolExecutor(1) as pool: |
| 35 | + yield DDBAuditingManager(database_uri=db_file.as_uri(), pool=pool, connection=conn) |
34 | 36 |
|
35 | 37 |
|
36 | 38 | @pytest.fixture |
|
0 commit comments