🚚 Refactor and simplify backend file structure (#609)
This commit is contained in:

committed by
GitHub

parent
a065f9c9e8
commit
73b2884057
27
src/backend/app/tests/utils/utils.py
Normal file
27
src/backend/app/tests/utils/utils.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import random
|
||||
import string
|
||||
from typing import Dict
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
|
||||
def random_lower_string() -> str:
|
||||
return "".join(random.choices(string.ascii_lowercase, k=32))
|
||||
|
||||
|
||||
def random_email() -> str:
|
||||
return f"{random_lower_string()}@{random_lower_string()}.com"
|
||||
|
||||
|
||||
def get_superuser_token_headers(client: TestClient) -> Dict[str, str]:
|
||||
login_data = {
|
||||
"username": settings.FIRST_SUPERUSER,
|
||||
"password": settings.FIRST_SUPERUSER_PASSWORD,
|
||||
}
|
||||
r = client.post(f"{settings.API_V1_STR}/login/access-token", data=login_data)
|
||||
tokens = r.json()
|
||||
a_token = tokens["access_token"]
|
||||
headers = {"Authorization": f"Bearer {a_token}"}
|
||||
return headers
|
Reference in New Issue
Block a user