mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-18 19:43:00 +03:00
cover events/search in sub label filter test
This commit is contained in:
@@ -492,21 +492,32 @@ class TestHttpApp(BaseTestHttp):
|
|||||||
"3.ascii": "Alice",
|
"3.ascii": "Alice",
|
||||||
"4.none": None,
|
"4.none": None,
|
||||||
}
|
}
|
||||||
|
mock_embeddings = Mock()
|
||||||
|
mock_embeddings.search_thumbnail.return_value = [(id, 0.1) for id in sub_labels]
|
||||||
|
|
||||||
|
self.app.frigate_config.semantic_search.enabled = True
|
||||||
|
self.app.embeddings = mock_embeddings
|
||||||
|
|
||||||
with AuthTestClient(self.app) as client:
|
with AuthTestClient(self.app) as client:
|
||||||
for id, sub_label in sub_labels.items():
|
for id, sub_label in sub_labels.items():
|
||||||
super().insert_mock_event(id)
|
super().insert_mock_event(id)
|
||||||
Event.update(sub_label=sub_label).where(Event.id == id).execute()
|
Event.update(sub_label=sub_label).where(Event.id == id).execute()
|
||||||
|
|
||||||
def ids(query: str) -> set[str]:
|
search_params = {"search_type": "similarity", "event_id": "1.cyrillic"}
|
||||||
events = client.get("/events", params={"sub_labels": query}).json()
|
|
||||||
return {event["id"] for event in events}
|
|
||||||
|
|
||||||
assert ids("Кузнецова Ира") == {"1.cyrillic"}
|
for path, params in (("/events", {}), ("/events/search", search_params)):
|
||||||
assert ids("Ира") == {"2.joined"}
|
|
||||||
assert ids("bob") == {"2.joined"}
|
def ids(query: str) -> set[str]:
|
||||||
assert ids("ALICE") == {"3.ascii"}
|
events = client.get(
|
||||||
assert ids("None") == {"4.none"}
|
path, params={**params, "sub_labels": query}
|
||||||
|
).json()
|
||||||
|
return {event["id"] for event in events}
|
||||||
|
|
||||||
|
assert ids("Кузнецова Ира") == {"1.cyrillic"}
|
||||||
|
assert ids("Ира") == {"2.joined"}
|
||||||
|
assert ids("bob") == {"2.joined"}
|
||||||
|
assert ids("ALICE") == {"3.ascii"}
|
||||||
|
assert ids("None") == {"4.none"}
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
################################### GET /metrics Endpoint #########################################################
|
################################### GET /metrics Endpoint #########################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user