def test_search_by_image_url_and_geo_box(channel): stub = service_pb2_grpc.V2Stub(channel) with SetupImage(stub) as input_: response = stub.PostInputsSearches( PostInputsSearchesRequest( searches=[ Search(query=Query(ranks=[ Rank(annotation=Annotation(data=Data(image=Image( url=DOG_IMAGE_URL)))), Rank(annotation=Annotation(data=Data( geo=resources_pb2.Geo(geo_box=[ resources_pb2.GeoBoxedPoint( geo_point=resources_pb2.GeoPoint( longitude=43, latitude=54)), resources_pb2.GeoBoxedPoint( geo_point=resources_pb2.GeoPoint( longitude=45, latitude=56)), ])))), ])) ], pagination=service_pb2.Pagination(page=1, per_page=1000), ), metadata=metadata(), ) raise_on_failure(response) assert len(response.hits) >= 1 assert input_.id in [hit.input.id for hit in response.hits]
def test_search_by_predicted_concept_name(channel): stub = service_pb2_grpc.V2Stub(channel) with SetupImage(stub) as input_: response = stub.PostInputsSearches( PostInputsSearchesRequest( searches=[ Search(query=Query(ranks=[ Rank(annotation=Annotation(data=Data( concepts=[Concept(name="dog", value=1)]))) ])) ], pagination=service_pb2.Pagination(page=1, per_page=1000), ), metadata=metadata(), ) raise_on_failure(response) assert len(response.hits) >= 1 assert input_.id in [hit.input.id for hit in response.hits]
def test_search_by_image_url(channel): stub = service_pb2_grpc.V2Stub(channel) with SetupImage(stub) as input_: response = stub.PostInputsSearches( PostInputsSearchesRequest( searches=[ Search(query=Query(ranks=[ Rank(annotation=Annotation(data=Data(image=Image( url=DOG_IMAGE_URL)))) ])) ], pagination=service_pb2.Pagination(page=1, per_page=1000), ), metadata=metadata(), ) raise_on_failure(response) assert len(response.hits) >= 1 assert input_.id in [hit.input.id for hit in response.hits]
def test_search_by_metadata(channel): stub = service_pb2_grpc.V2Stub(channel) search_metadata = struct_pb2.Struct() search_metadata.update({"another-key": {"inner-key": "inner-value"}}) with SetupImage(stub) as input_: response = stub.PostInputsSearches( PostInputsSearchesRequest( searches=[ Search(query=Query(ranks=[ Rank(annotation=Annotation(data=Data( metadata=search_metadata))) ])) ], pagination=service_pb2.Pagination(page=1, per_page=1000), ), metadata=metadata(), ) raise_on_failure(response) assert len(response.hits) >= 1 assert input_.id in [hit.input.id for hit in response.hits]
def test_search_by_geo_point_and_limit(channel): stub = service_pb2_grpc.V2Stub(channel) with SetupImage(stub) as input_: response = stub.PostInputsSearches( PostInputsSearchesRequest( searches=[ Search(query=Query(ranks=[ Rank(annotation=Annotation(data=Data( geo=resources_pb2.Geo( geo_point=resources_pb2.GeoPoint(longitude=43, latitude=56), geo_limit=resources_pb2.GeoLimit( value=1000, type="withinKilometers"), )))) ])) ], pagination=service_pb2.Pagination(page=1, per_page=1000), ), metadata=metadata(), ) raise_on_failure(response) assert len(response.hits) >= 1 assert input_.id in [hit.input.id for hit in response.hits]