Ejemplo n.º 1
0
    def test_get_model(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        display_name = "displayName1615086568"
        dataset_id = "datasetId-2115646910"
        expected_response = {
            "name": name_2,
            "display_name": display_name,
            "dataset_id": dataset_id,
        }
        expected_response = model_pb2.Model(**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 = automl_v1beta1.AutoMlClient()

        # Setup Request
        name = client.model_path("[PROJECT]", "[LOCATION]", "[MODEL]")

        response = client.get_model(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = service_pb2.GetModelRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_get_model(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        display_name = 'displayName1615086568'
        dataset_id = 'datasetId-2115646910'
        expected_response = {
            'name': name_2,
            'display_name': display_name,
            'dataset_id': dataset_id
        }
        expected_response = model_pb2.Model(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        client = automl_v1beta1.AutoMlClient(channel=channel)

        # Setup Request
        name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')

        response = client.get_model(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = service_pb2.GetModelRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request