def test_get_dataset(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        example_count = 1517063674
        etag = "etag3123477"
        expected_response = {
            "name": name_2,
            "display_name": display_name,
            "description": description,
            "example_count": example_count,
            "etag": etag,
        }
        expected_response = dataset_pb2.Dataset(**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_v1.AutoMlClient()

        # Setup Request
        name = client.dataset_path("[PROJECT]", "[LOCATION]", "[DATASET]")

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

        assert len(channel.requests) == 1
        expected_request = service_pb2.GetDatasetRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_update_dataset(self):
        # Setup Expected Response
        name = "name3373707"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        example_count = 1517063674
        etag = "etag3123477"
        expected_response = {
            "name": name,
            "display_name": display_name,
            "description": description,
            "example_count": example_count,
            "etag": etag,
        }
        expected_response = dataset_pb2.Dataset(**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_v1.AutoMlClient()

        # Setup Request
        dataset = {}
        update_mask = {}

        response = client.update_dataset(dataset, update_mask)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = service_pb2.UpdateDatasetRequest(
            dataset=dataset, update_mask=update_mask)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_create_dataset(self):
        # Setup Expected Response
        name = "name3373707"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        example_count = 1517063674
        etag = "etag3123477"
        expected_response = {
            "name": name,
            "display_name": display_name,
            "description": description,
            "example_count": example_count,
            "etag": etag,
        }
        expected_response = dataset_pb2.Dataset(**expected_response)
        operation = operations_pb2.Operation(
            name="operations/test_create_dataset", 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 = automl_v1.AutoMlClient()

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

        response = client.create_dataset(parent, dataset)
        result = response.result()
        assert expected_response == result

        assert len(channel.requests) == 1
        expected_request = service_pb2.CreateDatasetRequest(
            parent=parent, dataset=dataset
        )
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request