Spaces:
Build error
Build error
natexcvi
commited on
Commit
•
0e92099
1
Parent(s):
2f18963
Refactor auth test
Browse files- test_service.py +11 -11
test_service.py
CHANGED
@@ -72,18 +72,18 @@ def test_similarity(client: TestClient, image1_path, image2_path, exp_score):
|
|
72 |
assert response.json()["score"] == pytest.approx(exp_score, abs=1e-4)
|
73 |
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
response = client.post(
|
84 |
"/embed",
|
85 |
files=[("image", ("face_pic.jpeg", b""))],
|
86 |
-
params={"token":
|
87 |
)
|
88 |
-
assert response.status_code ==
|
89 |
-
assert response.json()["detail"] ==
|
|
|
72 |
assert response.json()["score"] == pytest.approx(exp_score, abs=1e-4)
|
73 |
|
74 |
|
75 |
+
@pytest.mark.parametrize(
|
76 |
+
"token, status_code, detail",
|
77 |
+
[
|
78 |
+
pytest.param(None, 401, "No token provided", id="no token"),
|
79 |
+
pytest.param("wrong_token", 401, "Invalid token", id="wrong token"),
|
80 |
+
],
|
81 |
+
)
|
82 |
+
def test_authentication(client: TestClient, token: str, status_code: int, detail: str):
|
83 |
response = client.post(
|
84 |
"/embed",
|
85 |
files=[("image", ("face_pic.jpeg", b""))],
|
86 |
+
params={"token": token} if token else {},
|
87 |
)
|
88 |
+
assert response.status_code == status_code
|
89 |
+
assert response.json()["detail"] == detail
|