|
16 | 16 | _DSN = "localhost:1521/freepdb1" |
17 | 17 |
|
18 | 18 |
|
19 | | -def _make_store(table: str, embedding_dim: int) -> OracleDocumentStore: |
20 | | - return OracleDocumentStore( |
21 | | - connection_config=OracleConnectionConfig( |
22 | | - user=Secret.from_token(_USER), |
23 | | - password=Secret.from_token(_PASSWORD), |
24 | | - dsn=Secret.from_token(_DSN), |
25 | | - ), |
26 | | - table_name=table, |
27 | | - embedding_dim=embedding_dim, |
28 | | - distance_metric="COSINE", |
29 | | - create_table_if_not_exists=True, |
30 | | - ) |
| 19 | +@pytest.fixture |
| 20 | +def make_store(): |
| 21 | + """Factory for a real OracleDocumentStore. Uses token secrets, so instances are not serialization-safe.""" |
| 22 | + |
| 23 | + def _make(table: str, embedding_dim: int = 4, *, create_table_if_not_exists: bool = True) -> OracleDocumentStore: |
| 24 | + return OracleDocumentStore( |
| 25 | + connection_config=OracleConnectionConfig( |
| 26 | + user=Secret.from_token(_USER), |
| 27 | + password=Secret.from_token(_PASSWORD), |
| 28 | + dsn=Secret.from_token(_DSN), |
| 29 | + ), |
| 30 | + table_name=table, |
| 31 | + embedding_dim=embedding_dim, |
| 32 | + create_table_if_not_exists=create_table_if_not_exists, |
| 33 | + ) |
| 34 | + |
| 35 | + return _make |
31 | 36 |
|
32 | 37 |
|
33 | 38 | @pytest.fixture |
34 | | -def document_store(): |
| 39 | +def document_store(make_store): |
35 | 40 | """768-dim store required by the mixin's filterable_docs fixture.""" |
36 | 41 | table = f"hs_sync_{uuid.uuid4().hex[:8]}" |
37 | | - s = _make_store(table, embedding_dim=768) |
| 42 | + s = make_store(table, 768) |
38 | 43 | yield s |
39 | 44 | with s._get_connection() as conn, conn.cursor() as cur: |
40 | 45 | cur.execute(f"DROP TABLE {table} PURGE") |
41 | 46 | conn.commit() |
42 | 47 |
|
43 | 48 |
|
44 | 49 | @pytest.fixture |
45 | | -def embedding_store(): |
| 50 | +def embedding_store(make_store): |
46 | 51 | """4-dim store for embedding-retrieval, HNSW, and async tests.""" |
47 | 52 | table = f"hs_emb_{uuid.uuid4().hex[:8]}" |
48 | | - s = _make_store(table, embedding_dim=4) |
| 53 | + s = make_store(table) |
49 | 54 | yield s |
50 | 55 | with s._get_connection() as conn, conn.cursor() as cur: |
51 | 56 | cur.execute(f"DROP TABLE {table} PURGE") |
|
0 commit comments