示例#1
0
    def test_get_model_evaluation(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        annotation_spec_id = 'annotationSpecId60690191'
        display_name = 'displayName1615086568'
        evaluated_example_count = 277565350
        expected_response = {
            'name': name_2,
            'annotation_spec_id': annotation_spec_id,
            'display_name': display_name,
            'evaluated_example_count': evaluated_example_count
        }
        expected_response = model_evaluation_pb2.ModelEvaluation(
            **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_evaluation_path('[PROJECT]', '[LOCATION]',
                                            '[MODEL]', '[MODEL_EVALUATION]')

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

        assert len(channel.requests) == 1
        expected_request = service_pb2.GetModelEvaluationRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
示例#2
0
    def test_get_model_evaluation(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        annotation_spec_id = "annotationSpecId60690191"
        display_name = "displayName1615086568"
        evaluated_example_count = 277565350
        expected_response = {
            "name": name_2,
            "annotation_spec_id": annotation_spec_id,
            "display_name": display_name,
            "evaluated_example_count": evaluated_example_count,
        }
        expected_response = model_evaluation_pb2.ModelEvaluation(**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_evaluation_path(
            "[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]"
        )

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

        assert len(channel.requests) == 1
        expected_request = service_pb2.GetModelEvaluationRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_get_model_evaluation(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        annotation_spec_id = 'annotationSpecId60690191'
        evaluated_example_count = 277565350
        expected_response = {
            'name': name_2,
            'annotation_spec_id': annotation_spec_id,
            'evaluated_example_count': evaluated_example_count
        }
        expected_response = model_evaluation_pb2.ModelEvaluation(
            **expected_response)

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

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

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

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