-
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.
- Loading branch information
1 parent
0bff8e1
commit 23f3f4c
Showing
6 changed files
with
86 additions
and
8 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
Empty file.
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,58 @@ | ||
import pytest | ||
from sqlalchemy.ext.asyncio import AsyncSession | ||
|
||
from app.db.models import Manga | ||
from tests.adapters.graphql.client import GraphQLClient | ||
from tests.factories import MangaTagFactory | ||
|
||
pytestmark = pytest.mark.anyio | ||
|
||
_QUERY = """query ($id: ID!) { | ||
manga(id: $id) { | ||
id | ||
tags { | ||
__typename | ||
id | ||
name | ||
slug | ||
} | ||
} | ||
} | ||
""" | ||
|
||
|
||
def _tpl(manga: object) -> object: | ||
return { | ||
"data": {"manga": manga}, | ||
} | ||
|
||
|
||
async def test_ok( | ||
collection_size: int, | ||
session: AsyncSession, | ||
manga: Manga, | ||
graphql_client: GraphQLClient, | ||
) -> None: | ||
manga.tags = MangaTagFactory.build_batch(size=collection_size) | ||
manga.tags.sort(key=lambda tag: tag.name_slug) | ||
session.add(manga) | ||
await session.flush() | ||
|
||
response = await graphql_client.query( | ||
query=_QUERY, | ||
variables={"id": str(manga.id)}, | ||
) | ||
assert response == _tpl( | ||
{ | ||
"id": str(manga.id), | ||
"tags": [ | ||
{ | ||
"__typename": "MangaTag", | ||
"id": str(tag.id), | ||
"name": tag.name, | ||
"slug": tag.name_slug, | ||
} | ||
for tag in manga.tags | ||
], | ||
}, | ||
) |
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