-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gauravr
committed
Feb 17, 2025
1 parent
88f7de7
commit 0b19a6d
Showing
3 changed files
with
464 additions
and
369 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
""" | ||
This file marks the root of tests. | ||
Common pytest fixtures can be defines here. | ||
See https://docs.pytest.org/en/latest/reference/fixtures.html | ||
""" | ||
|
||
import asyncio | ||
import pytest | ||
from httpx import ASGITransport, AsyncClient | ||
|
||
import settings | ||
from apphelpers.async_sessions import SessionDBHandler | ||
|
||
from fastapi_tests import service | ||
|
||
|
||
sessiondb_conn = dict( | ||
host=settings.SESSIONSDB_HOST, | ||
port=settings.SESSIONSDB_PORT, | ||
password=settings.SESSIONSDB_PASSWD, | ||
db=settings.SESSIONSDB_NO, | ||
) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def anyio_backend(): | ||
return "asyncio" | ||
|
||
|
||
@pytest.fixture | ||
def event_loop(): | ||
loop = asyncio.get_event_loop() | ||
yield loop | ||
loop.close() | ||
|
||
|
||
@pytest.fixture | ||
async def sessionsdb(): | ||
sessionsdb = SessionDBHandler(sessiondb_conn) | ||
yield sessionsdb | ||
await sessionsdb.close() | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
async def client(): | ||
async with AsyncClient( | ||
transport=ASGITransport(app=service.app), base_url="http://test" | ||
) as ac: | ||
yield ac |
Oops, something went wrong.