Skip to content

Commit

Permalink
Add tests for tags endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
borys25ol committed Apr 19, 2024
1 parent 351b03b commit e5f266c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/api/routes/test_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest
from httpx import AsyncClient

from conduit.domain.dtos.article import ArticleDTO


@pytest.mark.anyio
async def test_empty_list_when_no_tags_exist(test_client: AsyncClient) -> None:
response = await test_client.get(url="/tags")
assert response.json() == {"tags": []}


@pytest.mark.anyio
async def test_list_of_tags_when_article_with_tags_exists(
authorized_test_client: AsyncClient, test_article: ArticleDTO
) -> None:
response = await authorized_test_client.get(url="/tags")
response_tags = response.json()["tags"]
assert len(response_tags) == len(set(test_article.tags))
assert all(tag in test_article.tags for tag in response_tags)

0 comments on commit e5f266c

Please sign in to comment.