pytest-girder 5.0.8.dev4__tar.gz → 5.0.9.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_girder-5.0.8.dev4/pytest_girder.egg-info → pytest_girder-5.0.9.dev2}/PKG-INFO +1 -1
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder/fixtures.py +70 -7
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2/pytest_girder.egg-info}/PKG-INFO +1 -1
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/LICENSE +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/MANIFEST.in +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pyproject.toml +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder/__init__.py +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder/assertions.py +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder/plugin.py +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder/plugin_registry.py +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder/utils.py +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder/web_client.py +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder.egg-info/SOURCES.txt +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder.egg-info/dependency_links.txt +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder.egg-info/entry_points.txt +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder.egg-info/requires.txt +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder.egg-info/top_level.txt +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/setup.cfg +0 -0
- {pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/setup.py +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import hashlib
|
|
2
2
|
import os
|
|
3
3
|
import shutil
|
|
4
|
+
import threading
|
|
5
|
+
import time
|
|
4
6
|
import unittest.mock
|
|
5
7
|
|
|
6
8
|
import mongomock
|
|
7
9
|
import pytest
|
|
8
10
|
|
|
9
11
|
from .plugin_registry import PluginRegistry
|
|
10
|
-
from .utils import serverContext
|
|
12
|
+
from .utils import _findFreePort, serverContext
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
def _uid(node):
|
|
@@ -60,7 +62,11 @@ def db(request):
|
|
|
60
62
|
# Since models store a local reference to the current database, we need to force them all to
|
|
61
63
|
# reconnect
|
|
62
64
|
for model in model_base._modelSingletons:
|
|
63
|
-
|
|
65
|
+
try:
|
|
66
|
+
model.reconnect()
|
|
67
|
+
except OSError:
|
|
68
|
+
# Ignore lazy index creation errors
|
|
69
|
+
pass
|
|
64
70
|
|
|
65
71
|
# Use faster password hashing to avoid unnecessary testing bottlenecks. Any test case
|
|
66
72
|
# that creates a user goes through the password hashing process, so we avoid actual bcrypt.
|
|
@@ -145,6 +151,52 @@ def boundServer(db, request):
|
|
|
145
151
|
yield server
|
|
146
152
|
|
|
147
153
|
|
|
154
|
+
@pytest.fixture
|
|
155
|
+
def asgiBoundServer(db, request):
|
|
156
|
+
"""
|
|
157
|
+
Require an ASGI server that listens on a port.
|
|
158
|
+
|
|
159
|
+
Provides a started uvicorn server with a bound port. The returned value has
|
|
160
|
+
a `boundPort` property identifying where the server can be reached.
|
|
161
|
+
"""
|
|
162
|
+
import uvicorn
|
|
163
|
+
|
|
164
|
+
from girder.asgi import _WSGIBridge
|
|
165
|
+
|
|
166
|
+
registry = PluginRegistry()
|
|
167
|
+
with registry():
|
|
168
|
+
plugins = _getPluginsFromMarker(request, registry)
|
|
169
|
+
with serverContext(plugins, bindPort=False) as server_fixture:
|
|
170
|
+
port = _findFreePort()
|
|
171
|
+
server_fixture.boundPort = port
|
|
172
|
+
config = uvicorn.Config(
|
|
173
|
+
_WSGIBridge(server_fixture.serverRoot),
|
|
174
|
+
host='127.0.0.1',
|
|
175
|
+
port=port,
|
|
176
|
+
log_level='warning',
|
|
177
|
+
server_header=False,
|
|
178
|
+
date_header=False,
|
|
179
|
+
lifespan='off',
|
|
180
|
+
access_log=False,
|
|
181
|
+
loop='asyncio',
|
|
182
|
+
)
|
|
183
|
+
asgi_server = uvicorn.Server(config)
|
|
184
|
+
thread = threading.Thread(target=asgi_server.run, daemon=True)
|
|
185
|
+
thread.start()
|
|
186
|
+
deadline = time.monotonic() + 10
|
|
187
|
+
while not asgi_server.started and thread.is_alive() and time.monotonic() < deadline:
|
|
188
|
+
time.sleep(0.01)
|
|
189
|
+
if not asgi_server.started:
|
|
190
|
+
asgi_server.should_exit = True
|
|
191
|
+
thread.join(timeout=5)
|
|
192
|
+
raise RuntimeError('ASGI server failed to start')
|
|
193
|
+
try:
|
|
194
|
+
yield server_fixture
|
|
195
|
+
finally:
|
|
196
|
+
asgi_server.should_exit = True
|
|
197
|
+
thread.join(timeout=5)
|
|
198
|
+
|
|
199
|
+
|
|
148
200
|
@pytest.fixture
|
|
149
201
|
def email_stdout(db):
|
|
150
202
|
old_env_val = os.environ.get('GIRDER_EMAIL_TO_CONSOLE')
|
|
@@ -199,21 +251,32 @@ def fsAssetstore(db, request):
|
|
|
199
251
|
path = os.path.join(ROOT_DIR, 'tests', 'assetstore', name)
|
|
200
252
|
|
|
201
253
|
if os.path.isdir(path):
|
|
202
|
-
|
|
254
|
+
for _ in range(5):
|
|
255
|
+
try:
|
|
256
|
+
shutil.rmtree(path)
|
|
257
|
+
break
|
|
258
|
+
except Exception:
|
|
259
|
+
time.sleep(1)
|
|
203
260
|
|
|
204
261
|
yield Assetstore().createFilesystemAssetstore(name=name, root=path)
|
|
205
262
|
|
|
206
263
|
if os.path.isdir(path):
|
|
207
|
-
|
|
264
|
+
for _ in range(5):
|
|
265
|
+
try:
|
|
266
|
+
shutil.rmtree(path)
|
|
267
|
+
break
|
|
268
|
+
except Exception:
|
|
269
|
+
time.sleep(1)
|
|
208
270
|
|
|
209
271
|
|
|
210
272
|
__all__ = (
|
|
211
273
|
'admin',
|
|
274
|
+
'asgiBoundServer',
|
|
275
|
+
'boundServer',
|
|
212
276
|
'db',
|
|
277
|
+
'eagerWorkerTasks',
|
|
278
|
+
'email_stdout',
|
|
213
279
|
'fsAssetstore',
|
|
214
280
|
'server',
|
|
215
|
-
'boundServer',
|
|
216
281
|
'user',
|
|
217
|
-
'email_stdout',
|
|
218
|
-
'eagerWorkerTasks',
|
|
219
282
|
)
|
|
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
|
|
File without changes
|
{pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{pytest_girder-5.0.8.dev4 → pytest_girder-5.0.9.dev2}/pytest_girder.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|