Ejemplo n.º 1
0
    def test_add_product_to_product_set(self):
        channel = ChannelStub()
        client = vision_v1.ProductSearchClient(channel=channel)

        # Setup Request
        name = client.product_set_path('[PROJECT]', '[LOCATION]',
                                       '[PRODUCT_SET]')
        product = 'product-309474065'

        client.add_product_to_product_set(name, product)

        assert len(channel.requests) == 1
        expected_request = product_search_service_pb2.AddProductToProductSetRequest(
            name=name, product=product)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_add_product_to_product_set(self):
        channel = ChannelStub()
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = vision_v1.ProductSearchClient()

        # Setup Request
        name = client.product_set_path("[PROJECT]", "[LOCATION]",
                                       "[PRODUCT_SET]")
        product = client.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")

        client.add_product_to_product_set(name, product)

        assert len(channel.requests) == 1
        expected_request = product_search_service_pb2.AddProductToProductSetRequest(
            name=name, product=product)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request