mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 20:36:27 +00:00
🎨 Format files with pre-commit and Ruff (#611)
This commit is contained in:
committed by
GitHub
parent
2802a4df9e
commit
0cc802eec8
@@ -1,5 +1,3 @@
|
||||
from typing import Dict
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
@@ -10,7 +8,7 @@ from app.tests.utils.utils import random_email, random_lower_string
|
||||
|
||||
|
||||
def test_get_users_superuser_me(
|
||||
client: TestClient, superuser_token_headers: Dict[str, str]
|
||||
client: TestClient, superuser_token_headers: dict[str, str]
|
||||
) -> None:
|
||||
r = client.get(f"{settings.API_V1_STR}/users/me", headers=superuser_token_headers)
|
||||
current_user = r.json()
|
||||
@@ -21,7 +19,7 @@ def test_get_users_superuser_me(
|
||||
|
||||
|
||||
def test_get_users_normal_user_me(
|
||||
client: TestClient, normal_user_token_headers: Dict[str, str]
|
||||
client: TestClient, normal_user_token_headers: dict[str, str]
|
||||
) -> None:
|
||||
r = client.get(f"{settings.API_V1_STR}/users/me", headers=normal_user_token_headers)
|
||||
current_user = r.json()
|
||||
@@ -38,7 +36,9 @@ def test_create_user_new_email(
|
||||
password = random_lower_string()
|
||||
data = {"email": username, "password": password}
|
||||
r = client.post(
|
||||
f"{settings.API_V1_STR}/users/", headers=superuser_token_headers, json=data,
|
||||
f"{settings.API_V1_STR}/users/",
|
||||
headers=superuser_token_headers,
|
||||
json=data,
|
||||
)
|
||||
assert 200 <= r.status_code < 300
|
||||
created_user = r.json()
|
||||
@@ -56,7 +56,8 @@ def test_get_existing_user(
|
||||
user = crud.user.create(db, obj_in=user_in)
|
||||
user_id = user.id
|
||||
r = client.get(
|
||||
f"{settings.API_V1_STR}/users/{user_id}", headers=superuser_token_headers,
|
||||
f"{settings.API_V1_STR}/users/{user_id}",
|
||||
headers=superuser_token_headers,
|
||||
)
|
||||
assert 200 <= r.status_code < 300
|
||||
api_user = r.json()
|
||||
@@ -75,7 +76,9 @@ def test_create_user_existing_username(
|
||||
crud.user.create(db, obj_in=user_in)
|
||||
data = {"email": username, "password": password}
|
||||
r = client.post(
|
||||
f"{settings.API_V1_STR}/users/", headers=superuser_token_headers, json=data,
|
||||
f"{settings.API_V1_STR}/users/",
|
||||
headers=superuser_token_headers,
|
||||
json=data,
|
||||
)
|
||||
created_user = r.json()
|
||||
assert r.status_code == 400
|
||||
@@ -83,13 +86,15 @@ def test_create_user_existing_username(
|
||||
|
||||
|
||||
def test_create_user_by_normal_user(
|
||||
client: TestClient, normal_user_token_headers: Dict[str, str]
|
||||
client: TestClient, normal_user_token_headers: dict[str, str]
|
||||
) -> None:
|
||||
username = random_email()
|
||||
password = random_lower_string()
|
||||
data = {"email": username, "password": password}
|
||||
r = client.post(
|
||||
f"{settings.API_V1_STR}/users/", headers=normal_user_token_headers, json=data,
|
||||
f"{settings.API_V1_STR}/users/",
|
||||
headers=normal_user_token_headers,
|
||||
json=data,
|
||||
)
|
||||
assert r.status_code == 400
|
||||
|
||||
|
||||
Reference in New Issue
Block a user