mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-11-30 13:20:40 +03:00
code format
This commit is contained in:
@@ -2,18 +2,36 @@ import pytest
|
||||
from httpx import AsyncClient
|
||||
from starlette import status
|
||||
import jwt
|
||||
from inline_snapshot import snapshot
|
||||
from dirty_equals import IsStr, IsUUID, IsPositiveFloat
|
||||
|
||||
pytestmark = pytest.mark.anyio
|
||||
|
||||
|
||||
# TODO: parametrize test with diff urls
|
||||
async def test_add_user(client: AsyncClient):
|
||||
payload = {"email": "joe@grillazz.com", "first_name": "Joe", "last_name": "Garcia", "password": "s1lly"}
|
||||
payload = {
|
||||
"email": "joe@grillazz.com",
|
||||
"first_name": "Joe",
|
||||
"last_name": "Garcia",
|
||||
"password": "s1lly",
|
||||
}
|
||||
response = await client.post("/user/", json=payload)
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
claimset = jwt.decode(response.json()["access_token"], options={"verify_signature": False})
|
||||
assert claimset["email"] == payload["email"]
|
||||
assert claimset["expiry"] > 0
|
||||
assert response.json() == snapshot(
|
||||
{
|
||||
"id": IsUUID(4),
|
||||
"email": "joe@grillazz.com",
|
||||
"first_name": "Joe",
|
||||
"last_name": "Garcia",
|
||||
"access_token": IsStr(),
|
||||
}
|
||||
)
|
||||
|
||||
claimset = jwt.decode(
|
||||
response.json()["access_token"], options={"verify_signature": False}
|
||||
)
|
||||
assert claimset["expiry"] == IsPositiveFloat()
|
||||
assert claimset["platform"] == "python-httpx/0.27.0"
|
||||
|
||||
|
||||
@@ -22,9 +40,11 @@ async def test_get_token(client: AsyncClient):
|
||||
payload = {"email": "joe@grillazz.com", "password": "s1lly"}
|
||||
response = await client.post("/user/token", json=payload)
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
claimset = jwt.decode(response.json()["access_token"], options={"verify_signature": False})
|
||||
claimset = jwt.decode(
|
||||
response.json()["access_token"], options={"verify_signature": False}
|
||||
)
|
||||
assert claimset["email"] == payload["email"]
|
||||
assert claimset["expiry"] > 0
|
||||
assert claimset["expiry"] == IsPositiveFloat()
|
||||
assert claimset["platform"] == "python-httpx/0.27.0"
|
||||
|
||||
|
||||
|
||||
@@ -24,4 +24,4 @@ async def test_import_animals(client: AsyncClient):
|
||||
)
|
||||
|
||||
assert response.status_code == expected_status
|
||||
assert response.json() == {'filename': 'nonsense.xlsx', 'nonsense_records': 10}
|
||||
assert response.json() == {"filename": "nonsense.xlsx", "nonsense_records": 10}
|
||||
|
||||
@@ -32,7 +32,6 @@ async def client(start_db) -> AsyncClient:
|
||||
|
||||
transport = ASGITransport(
|
||||
app=app,
|
||||
|
||||
)
|
||||
async with AsyncClient(
|
||||
# app=app,
|
||||
|
||||
Reference in New Issue
Block a user