Skip to content

Commit

Permalink
update tests (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragjn authored Jun 24, 2024
1 parent cab301d commit 8c902ad
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions libs/infinity_emb/tests/end_to_end/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ async def client():

@pytest.mark.anyio
async def test_authentication(client):
assert (await client.get("/models")).status_code == 200

for route, payload in [
["/embeddings", {"model": MODEL_NAME, "input": "sentence"}],
for method, route, payload in [
["GET", "/models", None],
["POST", "/embeddings", {"model": MODEL_NAME, "input": "sentence"}],
[
"POST",
"/rerank",
{
"model": MODEL_NAME,
Expand All @@ -55,11 +55,12 @@ async def test_authentication(client):
]:
for authenticated in [False, True]:
headers = {"Authorization": f"Bearer {API_KEY}"} if authenticated else {}
response = await client.post(
response = await client.request(
method,
route,
headers=headers,
json=payload,
)
assert (response).status_code in (
[200, 400] if authenticated else [403]
[200, 400] if authenticated else [401]
), f"route: {route}, payload: {payload}, response: {response.json()}"

0 comments on commit 8c902ad

Please sign in to comment.