-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
9057734
commit b61dfcd
Showing
4 changed files
with
111 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -8,3 +8,4 @@ mypy==1.4.1 | |
pre-commit==3.3.3 | ||
pytest==7.3.1 | ||
pytest-cov==4.1.0 | ||
pytest-asyncio |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import pytest | ||
|
||
from tests.book import Book | ||
from tests.helpers import mock_aio_http | ||
|
||
|
||
@pytest.fixture | ||
def mock_get_book(monkeypatch): | ||
mock_resp = {"name": "name", "age": 1} | ||
yield mock_aio_http(monkeypatch, response=mock_resp) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_get(async_client, mock_get_book): | ||
book: Book = await async_client.get_book(1, "world") | ||
assert book.name == "name" | ||
assert book.age == 1 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_get_raw(async_client, mock_get_book): | ||
book: dict = await async_client.get_raw_book(1) | ||
assert book["name"] == "name" | ||
assert book["age"] == 1 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_post_form(async_client, mock_get_book): | ||
book: Book = await async_client.create_book_form(Book(name="name", age=2)) | ||
assert book.name == "name" | ||
assert book.age == 1 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_put(async_client, mock_get_book): | ||
book: Book = await async_client.change_book(1, Book(name="name", age=2)) | ||
assert book.name == "name" | ||
assert book.age == 1 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_delete(async_client, mock_get_book): | ||
book: Book = await async_client.delete_book(1) | ||
assert book.name == "name" | ||
assert book.age == 1 |