-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
29 lines (21 loc) · 855 Bytes
/
tests.py
File metadata and controls
29 lines (21 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pytest
import pytest_asyncio
from quart import Quart
from app import app
@pytest_asyncio.fixture(name="test_app", scope="function")
async def test_app():
async with app.test_app() as test_app:
yield test_app
@pytest.mark.asyncio
async def test_create_user(test_app: Quart) -> None:
test_client = test_app.test_client()
response = await test_client.post("/social_network/userregistration/", json={"name": "test_name"})
assert response.status_code == 200
data = await response.get_json()
assert "id" in data
assert data["name"] == "test_name"
@pytest.mark.asyncio
async def test_create_user_failure(test_app: Quart) -> None:
test_client = test_app.test_client()
response = await test_client.post("/social_network/userregistration/", json={"nam": "test_name"})
assert response.status_code == 400