-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathtest_api_users.py
More file actions
37 lines (31 loc) · 1.41 KB
/
test_api_users.py
File metadata and controls
37 lines (31 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def test_register_user_api(client):
# Given: 사용자의 ID와 얼굴 이미지가 주어짐
# Given: API 테스트 클라이언트가 fixture로 제공됨
image_path = "images/Aaron_Peirsol/Aaron_Peirsol_0001.jpg"
user_id = "aaron_peirsol"
# When: 사용자 등록 API (POST /users/register)를 호출
with open(image_path, "rb") as img_file:
response = client.post(
"/users/register",
data={"user_id": user_id},
files={"image": ("user1.jpg", img_file, "image/jpeg")},
)
# Then: 사용자 등록 기능이 성공(200)
# Then: 응답 내용은 등록된 사용자 ID 및 등록 시각이 포함
assert response.status_code == 200
data = response.json()
assert data["user_id"] == user_id
assert data["registered_at"] is not None
def test_authenticate_user_api(client, setup_user_db):
# Given: 등록된 사용자의 얼굴 이미지가 주어짐
image_path = "images/Aaron_Peirsol/Aaron_Peirsol_0001.jpg"
# When: 사용자 인증 API (POST /users/authenticate)를 호출
with open(image_path, "rb") as img_file:
response = client.post(
"/users/authenticate",
files={"image": ("user1.jpg", img_file, "image/jpeg")},
)
# Then: 사용자 인증 기능이 성공(200)
assert response.status_code == 200
data = response.json()
assert data["user_id"] == "aaron_peirsol"