Files
test-litestar-addressbook/tests/test_cities.py
2023-09-20 21:25:05 +02:00

29 lines
934 B
Python

import pytest
from litestar.status_codes import HTTP_200_OK
from litestar.testing import AsyncTestClient
from sqlalchemy.ext.asyncio import AsyncSession
from main import app
from tests.factories.city_factory import CityFactory
class TestCitiesEndpoints:
@pytest.fixture(scope="function", autouse=True)
def setup_class(self, db_session: AsyncSession):
self.db_session = db_session
@pytest.mark.asyncio
async def test_get(self):
city_1 = await CityFactory.create()
city_2 = await CityFactory.create()
city_3 = await CityFactory.create()
city_4 = await CityFactory.create()
city_5 = await CityFactory.create()
async with AsyncTestClient(app=app) as client:
response = await client.get("/v1/cities")
print("#" * 100)
print(response.content)
print("#" * 100)
assert response.status_code == HTTP_200_OK