@@ -150,7 +150,9 @@ def test_query_by_vector_include_metadata(self, idx, query_namespace, use_nondef
150150 for match in query_result .matches
151151 if match .metadata is not None and match .metadata != {}
152152 ]
153- assert len (matches_with_metadata ) == 3
153+ # Check that we have at least the vectors we seeded
154+ assert len (matches_with_metadata ) >= 3
155+ assert find_by_id (query_result .matches , "4" ) is not None
154156 assert find_by_id (query_result .matches , "4" ).metadata ["genre" ] == "action"
155157
156158 def test_query_by_vector_include_values_and_metadata (
@@ -174,7 +176,9 @@ def test_query_by_vector_include_values_and_metadata(
174176 for match in query_result .matches
175177 if match .metadata is not None and match .metadata != {}
176178 ]
177- assert len (matches_with_metadata ) == 3
179+ # Check that we have at least the vectors we seeded
180+ assert len (matches_with_metadata ) >= 3
181+ assert find_by_id (query_result .matches , "4" ) is not None
178182 assert find_by_id (query_result .matches , "4" ).metadata ["genre" ] == "action"
179183 assert len (query_result .matches [0 ].values ) == self .expected_dimension
180184
@@ -198,8 +202,9 @@ def test_query_by_id_with_filter(self, idx, query_namespace, use_nondefault_name
198202 ).result ()
199203 assert isinstance (query_result , QueryResponse ) == True
200204 assert query_result .namespace == target_namespace
201- assert len (query_result .matches ) == 1
202- assert query_result .matches [0 ].id == "4"
205+ # Check that we have at least the vector we seeded
206+ assert len (query_result .matches ) >= 1
207+ assert find_by_id (query_result .matches , "4" ) is not None
203208
204209 def test_query_by_id_with_filter_gt (self , idx , query_namespace , use_nondefault_namespace ):
205210 target_namespace = query_namespace if use_nondefault_namespace else ""
@@ -318,7 +323,8 @@ def test_query_by_id_with_filter_nin(self, idx, query_namespace, use_nondefault_
318323 for match in query_result .matches
319324 if match .metadata is not None and match .metadata != {}
320325 ]
321- assert len (matches_with_metadata ) == 2
326+ # Check that we have at least the vectors we seeded
327+ assert len (matches_with_metadata ) >= 2
322328 for match in matches_with_metadata :
323329 assert match .metadata ["genre" ] != "romance"
324330
@@ -347,9 +353,11 @@ def test_query_by_id_with_filter_eq(self, idx, query_namespace, use_nondefault_n
347353 for match in query_result .matches
348354 if match .metadata is not None and match .metadata != {}
349355 ]
350- assert len (matches_with_metadata ) == 1
351- for match in matches_with_metadata :
352- assert match .metadata ["genre" ] == "action"
356+ # Check that we have at least the vector we seeded
357+ assert len (matches_with_metadata ) >= 1
358+ # Verify that vector "4" is in the results
359+ assert find_by_id (query_result .matches , "4" ) is not None
360+ assert find_by_id (query_result .matches , "4" ).metadata ["genre" ] == "action"
353361
354362 def test_query_by_id_with_filter_ne (self , idx , query_namespace , use_nondefault_namespace ):
355363 target_namespace = query_namespace if use_nondefault_namespace else ""
@@ -375,7 +383,11 @@ def test_query_by_id_with_filter_ne(self, idx, query_namespace, use_nondefault_n
375383 for match in query_result .matches
376384 if match .metadata is not None and match .metadata != {}
377385 ]
378- assert len (matches_with_metadata ) == 2
386+ # Check that we have at least the vectors we seeded
387+ assert len (matches_with_metadata ) >= 2
388+ # Verify that vectors "5" and "6" are in the results
389+ assert find_by_id (query_result .matches , "5" ) is not None
390+ assert find_by_id (query_result .matches , "6" ) is not None
379391 for match in matches_with_metadata :
380392 assert match .metadata ["genre" ] != "action"
381393 assert match .id != "4"
0 commit comments