-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mock AsyncClient with app for performance gains
- Loading branch information
Showing
9 changed files
with
91 additions
and
60 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,22 +1,40 @@ | ||
# pylint: disable=redefined-outer-name, missing-function-docstring, missing-module-docstring | ||
# pylint: disable=protected-access | ||
|
||
from typing import Iterator | ||
from unittest import mock | ||
|
||
import httpx | ||
import pytest | ||
|
||
from bavapi.client import Client | ||
from bavapi.http import HTTPClient | ||
|
||
from tests.helpers import mock_app | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def anyio_backend() -> str: | ||
return "asyncio" | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def client() -> HTTPClient: | ||
return HTTPClient("test") | ||
def http_client(): | ||
return httpx.AsyncClient(app=mock_app) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def client(http_client: httpx.AsyncClient) -> HTTPClient: | ||
return HTTPClient(client=http_client) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def fount(client: HTTPClient) -> Client: | ||
return Client(client=client) | ||
|
||
|
||
@pytest.fixture | ||
def mock_async_client() -> Iterator[httpx.AsyncClient]: | ||
async_client = httpx.AsyncClient(app=mock_app) | ||
with mock.patch("httpx.AsyncClient", return_value=async_client) as mock_client: | ||
yield mock_client |
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