-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/WordPress/openverse into in…
…t_test_using_client
- Loading branch information
Showing
28 changed files
with
259 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,18 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
from conf.asgi import application | ||
|
||
|
||
@pytest.fixture | ||
def get_new_loop(): | ||
loops: list[asyncio.AbstractEventLoop] = [] | ||
|
||
def _get_new_loop() -> asyncio.AbstractEventLoop: | ||
loop = asyncio.new_event_loop() | ||
loops.append(loop) | ||
return loop | ||
|
||
yield _get_new_loop | ||
|
||
for loop in loops: | ||
loop.close() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def session_loop() -> asyncio.AbstractEventLoop: | ||
loop = asyncio.new_event_loop() | ||
yield loop | ||
loop.close() | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def ensure_asgi_lifecycle(session_loop: asyncio.AbstractEventLoop): | ||
""" | ||
Call application shutdown lifecycle event. | ||
This cannot be an async fixture because the scope is session | ||
and pytest-asynio's `event_loop` fixture, which is auto-used | ||
for async tests and fixtures, is function scoped, which is | ||
incomatible with session scoped fixtures. `async_to_sync` works | ||
fine here, so it's not a problem. | ||
This cannot yet call the startup signal due to: | ||
https://github.com/illagrenan/django-asgi-lifespan/pull/80 | ||
""" | ||
scope = {"type": "lifespan"} | ||
|
||
async def noop(*args, **kwargs): | ||
... | ||
|
||
async def shutdown(): | ||
return {"type": "lifespan.shutdown"} | ||
|
||
yield | ||
session_loop.run_until_complete(application(scope, shutdown, noop)) | ||
from test.fixtures.asynchronous import ensure_asgi_lifecycle, get_new_loop, session_loop | ||
from test.fixtures.cache import ( | ||
django_cache, | ||
redis, | ||
unreachable_django_cache, | ||
unreachable_redis, | ||
) | ||
|
||
|
||
__all__ = [ | ||
"ensure_asgi_lifecycle", | ||
"get_new_loop", | ||
"session_loop", | ||
"django_cache", | ||
"redis", | ||
"unreachable_django_cache", | ||
"unreachable_redis", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.