def test_list_reference_images(self): # Setup Expected Response page_size = 883849137 next_page_token = "" reference_images_element = {} reference_images = [reference_images_element] expected_response = { "page_size": page_size, "next_page_token": next_page_token, "reference_images": reference_images, } expected_response = product_search_service_pb2.ListReferenceImagesResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = vision_v1p3beta1.ProductSearchClient() # Setup Request parent = client.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]") paged_list_response = client.list_reference_images(parent) resources = list(paged_list_response) assert len(resources) == 1 assert expected_response.reference_images[0] == resources[0] assert len(channel.requests) == 1 expected_request = product_search_service_pb2.ListReferenceImagesRequest( parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_list_reference_images(self): # Setup Expected Response page_size = 883849137 next_page_token = '' reference_images_element = {} reference_images = [reference_images_element] expected_response = { 'page_size': page_size, 'next_page_token': next_page_token, 'reference_images': reference_images } expected_response = product_search_service_pb2.ListReferenceImagesResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = vision_v1p3beta1.ProductSearchClient(channel=channel) # Setup Request parent = client.product_path('[PROJECT]', '[LOCATION]', '[PRODUCT]') paged_list_response = client.list_reference_images(parent) resources = list(paged_list_response) assert len(resources) == 1 assert expected_response.reference_images[0] == resources[0] assert len(channel.requests) == 1 expected_request = product_search_service_pb2.ListReferenceImagesRequest( parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request