Skip to content

Commit

Permalink
test: add search with several storages
Browse files Browse the repository at this point in the history
  • Loading branch information
bathienle committed Aug 27, 2024
1 parent 570a303 commit 34ef874
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,48 @@ def test_search_one_image(client: TestClient) -> None:
assert len(data["similarities"]) == 1


def test_search_one_image_with_storages(client: TestClient) -> None:
"""
Test 'POST /api/search' for one neighbour with several storages.
Args:
client: A test client instance used to send requests to the application.
"""

storages = ["test_storage1", "test_storage2"]
index_name = "test_index"

for storage in storages:
response = client.post("/api/storages", json={"name": storage})
assert response.status_code == 200

with open("tests/data/image.png", "rb") as file:
response = client.post(
"/api/images",
files={"image": file},
params={"storage": storage, "index": index_name},
)
assert response.status_code == 200

with open("tests/data/image.png", "rb") as image:
response = client.post(
"/api/search",
files={"image": image},
params={
"nrt_neigh": "1",
"storage": storages,
"index": index_name,
},
)

data = response.json()

assert response.status_code == 200
assert "similarities" in data
assert isinstance(data["similarities"], list)
assert len(data["similarities"]) == 1


def test_search_images(client: TestClient) -> None:
"""
Test 'POST /api/search' for several neighbours.
Expand Down

0 comments on commit 34ef874

Please sign in to comment.