just for sync

develop
Сергей Ванюшкин 2024-01-26 09:52:35 +00:00
parent 0ae3293730
commit f09b5b57b2
1 changed files with 22 additions and 13 deletions

View File

@ -1,21 +1,30 @@
import pytest import pytest
from httpx import AsyncClient from httpx import AsyncClient
url = "http://localhost:8000/api/v1/menus" url = "http://localhost:8000/api/v1/menus"
@pytest.mark.asyncio class TestCrud:
async def test_read_menus(app): @pytest.mark.asyncio
async with AsyncClient(app=app, base_url=url) as ac: async def test_read_menus(self, app):
response = await ac.get("/") """тест пустой бд"""
assert response.status_code == 200 async with AsyncClient(app=app, base_url=url) as ac:
assert response.json() == [] response = await ac.get("/")
assert response.status_code == 200
assert response.json() == []
@pytest.mark.asyncio
async def test_write_menu(self, app):
""""""
async with AsyncClient(app=app, base_url=url) as ac:
response = await ac.post("/", json={"title": "menu 1", "description": None})
assert response.status_code == 201
assert response.json()["title"] == "menu 1"
assert response.json()["description"] == None
@pytest.mark.asyncio class TestСontinuity:
async def test_write_menu(app): @pytest.mark.asyncio
async with AsyncClient(app=app, base_url=url) as ac: async def test_postman_continuity(self, app):
response = await ac.post("/", json={"title": "ddd", "description": "hh"}) async with AsyncClient(app=app, base_url=url) as ac:
assert response.status_code == 201 pass
assert response.json()["title"] == "ddd"