def test_import_product_sets(self):
        # Setup Expected Response
        expected_response = {}
        expected_response = product_search_service_pb2.ImportProductSetsResponse(
            **expected_response)
        operation = operations_pb2.Operation(
            name="operations/test_import_product_sets", done=True)
        operation.response.Pack(expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[operation])
        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
        parent = client.location_path("[PROJECT]", "[LOCATION]")
        input_config = {}

        response = client.import_product_sets(parent, input_config)
        result = response.result()
        assert expected_response == result

        assert len(channel.requests) == 1
        expected_request = product_search_service_pb2.ImportProductSetsRequest(
            parent=parent, input_config=input_config)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Пример #2
0
    def test_import_product_sets(self):
        # Setup Expected Response
        expected_response = {}
        expected_response = product_search_service_pb2.ImportProductSetsResponse(
            **expected_response)
        operation = operations_pb2.Operation(
            name='operations/test_import_product_sets', done=True)
        operation.response.Pack(expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[operation])
        client = vision_v1.ProductSearchClient(channel=channel)

        # Setup Request
        parent = client.location_path('[PROJECT]', '[LOCATION]')
        input_config = {}

        response = client.import_product_sets(parent, input_config)
        result = response.result()
        assert expected_response == result

        assert len(channel.requests) == 1
        expected_request = product_search_service_pb2.ImportProductSetsRequest(
            parent=parent, input_config=input_config)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request