diracx-testing 0.0.1a24__tar.gz → 0.0.1a25__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/PKG-INFO +1 -1
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx/testing/mock_osdb.py +10 -5
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx/testing/utils.py +14 -4
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx_testing.egg-info/PKG-INFO +1 -1
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/README.md +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/pyproject.toml +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/setup.cfg +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx/testing/__init__.py +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx/testing/dummy_osdb.py +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx/testing/entrypoints.py +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx/testing/osdb.py +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx/testing/routers.py +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx_testing.egg-info/SOURCES.txt +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx_testing.egg-info/dependency_links.txt +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx_testing.egg-info/requires.txt +0 -0
- {diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx_testing.egg-info/top_level.txt +0 -0
@@ -72,18 +72,22 @@ class MockOSDBMixin:
|
|
72
72
|
yield
|
73
73
|
|
74
74
|
async def __aenter__(self):
|
75
|
-
|
75
|
+
"""Enter the request context.
|
76
|
+
|
77
|
+
This is a no-op as the real OpenSearch class doesn't use transactions.
|
78
|
+
Instead we enter a transaction in each method that needs it.
|
79
|
+
"""
|
76
80
|
return self
|
77
81
|
|
78
82
|
async def __aexit__(self, exc_type, exc_value, traceback):
|
79
|
-
|
83
|
+
pass
|
80
84
|
|
81
85
|
async def create_index_template(self) -> None:
|
82
86
|
async with self._sql_db.engine.begin() as conn:
|
83
87
|
await conn.run_sync(self._sql_db.metadata.create_all)
|
84
88
|
|
85
89
|
async def upsert(self, doc_id, document) -> None:
|
86
|
-
async with self:
|
90
|
+
async with self._sql_db:
|
87
91
|
values = {}
|
88
92
|
for key, value in document.items():
|
89
93
|
if key in self.fields:
|
@@ -106,7 +110,7 @@ class MockOSDBMixin:
|
|
106
110
|
per_page: int = 100,
|
107
111
|
page: int | None = None,
|
108
112
|
) -> tuple[int, list[dict[Any, Any]]]:
|
109
|
-
async with self:
|
113
|
+
async with self._sql_db:
|
110
114
|
# Apply selection
|
111
115
|
if parameters:
|
112
116
|
columns = []
|
@@ -150,7 +154,8 @@ class MockOSDBMixin:
|
|
150
154
|
return results
|
151
155
|
|
152
156
|
async def ping(self):
|
153
|
-
|
157
|
+
async with self._sql_db:
|
158
|
+
return await self._sql_db.ping()
|
154
159
|
|
155
160
|
|
156
161
|
def fake_available_osdb_implementations(name, *, real_available_implementations):
|
@@ -252,6 +252,7 @@ class ClientFactory:
|
|
252
252
|
assert (
|
253
253
|
self.app.dependency_overrides == {} and self.app.lifetime_functions == []
|
254
254
|
), "configure cannot be nested"
|
255
|
+
|
255
256
|
for k, v in self.all_dependency_overrides.items():
|
256
257
|
|
257
258
|
class_name = k.__self__.__name__
|
@@ -284,17 +285,26 @@ class ClientFactory:
|
|
284
285
|
import sqlalchemy
|
285
286
|
from sqlalchemy.util.concurrency import greenlet_spawn
|
286
287
|
|
288
|
+
from diracx.db.os.utils import BaseOSDB
|
287
289
|
from diracx.db.sql.utils import BaseSQLDB
|
290
|
+
from diracx.testing.mock_osdb import MockOSDBMixin
|
288
291
|
|
289
292
|
for k, v in self.app.dependency_overrides.items():
|
290
|
-
# Ignore dependency overrides which aren't BaseSQLDB.transaction
|
291
|
-
if (
|
292
|
-
|
293
|
-
|
293
|
+
# Ignore dependency overrides which aren't BaseSQLDB.transaction or BaseOSDB.session
|
294
|
+
if isinstance(v, UnavailableDependency) or k.__func__ not in (
|
295
|
+
BaseSQLDB.transaction.__func__,
|
296
|
+
BaseOSDB.session.__func__,
|
294
297
|
):
|
298
|
+
|
295
299
|
continue
|
300
|
+
|
296
301
|
# The first argument of the overridden BaseSQLDB.transaction is the DB object
|
297
302
|
db = v.args[0]
|
303
|
+
# We expect the OS DB to be mocked with sqlite, so use the
|
304
|
+
# internal DB
|
305
|
+
if isinstance(db, MockOSDBMixin):
|
306
|
+
db = db._sql_db
|
307
|
+
|
298
308
|
assert isinstance(db, BaseSQLDB), (k, db)
|
299
309
|
|
300
310
|
# set PRAGMA foreign_keys=ON if sqlite
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx_testing.egg-info/dependency_links.txt
RENAMED
File without changes
|
{diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx_testing.egg-info/requires.txt
RENAMED
File without changes
|
{diracx_testing-0.0.1a24 → diracx_testing-0.0.1a25}/src/diracx_testing.egg-info/top_level.txt
RENAMED
File without changes
|