def test_get_annotated_dataset(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        example_count = 1517063674
        completed_example_count = 612567290
        expected_response = {
            "name": name_2,
            "display_name": display_name,
            "description": description,
            "example_count": example_count,
            "completed_example_count": completed_example_count,
        }
        expected_response = dataset_pb2.AnnotatedDataset(**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 = datalabeling_v1beta1.DataLabelingServiceClient()

        # Setup Request
        name = client.annotated_dataset_path("[PROJECT]", "[DATASET]",
                                             "[ANNOTATED_DATASET]")

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

        assert len(channel.requests) == 1
        expected_request = data_labeling_service_pb2.GetAnnotatedDatasetRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_label_audio(self):
        # Setup Expected Response
        name = "name3373707"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        example_count = 1517063674
        completed_example_count = 612567290
        expected_response = {
            "name": name,
            "display_name": display_name,
            "description": description,
            "example_count": example_count,
            "completed_example_count": completed_example_count,
        }
        expected_response = dataset_pb2.AnnotatedDataset(**expected_response)
        operation = longrunning_operations_pb2.Operation(
            name="operations/test_label_audio", 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 = datalabeling_v1beta1.DataLabelingServiceClient()

        # Setup Request
        parent = client.dataset_path("[PROJECT]", "[DATASET]")
        basic_config = {}
        feature = enums.LabelAudioRequest.Feature.FEATURE_UNSPECIFIED

        response = client.label_audio(parent, basic_config, feature)
        result = response.result()
        assert expected_response == result

        assert len(channel.requests) == 1
        expected_request = data_labeling_service_pb2.LabelAudioRequest(
            parent=parent, basic_config=basic_config, feature=feature)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request