Files
dylan 06a0a33a3a Update tests structure. (#68)
* Update tests structure.
* Unit tests use the test database
* Add function for creating database engine and session.
2023-05-23 17:52:34 +08:00

22 lines
685 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from starlette.testclient import TestClient
from backend.app.core.conf import settings
def test_login(client: TestClient) -> None:
data = {
'username': 'test',
'password': 'test',
}
response = client.post(f'{settings.API_V1_STR}/auth/login', json=data)
assert response.status_code == 200
assert response.json()['data']['access_token_type'] == 'Bearer'
def test_logout(client: TestClient, token_headers: dict[str, str]) -> None:
response = client.post(f'{settings.API_V1_STR}/auth/logout', headers=token_headers)
assert response.status_code == 200
assert response.json()['code'] == 200