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

20 lines
611 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from typing import Dict
from starlette.testclient import TestClient
from backend.app.core.conf import settings
def get_token_headers(client: TestClient, username: str, password: str) -> Dict[str, str]:
data = {
'username': username,
'password': password,
}
response = client.post(f'{settings.API_V1_STR}/auth/login', json=data)
token_type = response.json()['data']['access_token_type']
access_token = response.json()['data']['access_token']
headers = {'Authorization': f'{token_type} {access_token}'}
return headers