def test_lookup_entry(self):
        # Setup Expected Response
        name = "name3373707"
        linked_resource = "linkedResource1544625012"
        user_specified_type = "userSpecifiedType-940364963"
        user_specified_system = "userSpecifiedSystem-1776119406"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        expected_response = {
            "name": name,
            "linked_resource": linked_resource,
            "user_specified_type": user_specified_type,
            "user_specified_system": user_specified_system,
            "display_name": display_name,
            "description": description,
        }
        expected_response = datacatalog_pb2.Entry(**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 = datacatalog_v1beta1.DataCatalogClient()

        response = client.lookup_entry()
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = datacatalog_pb2.LookupEntryRequest()
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_update_entry(self):
        # Setup Expected Response
        name = "name3373707"
        linked_resource = "linkedResource1544625012"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        expected_response = {
            "name": name,
            "linked_resource": linked_resource,
            "display_name": display_name,
            "description": description,
        }
        expected_response = datacatalog_pb2.Entry(**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 = datacatalog_v1beta1.DataCatalogClient()

        # Setup Request
        entry = {}

        response = client.update_entry(entry)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = datacatalog_pb2.UpdateEntryRequest(entry=entry)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_get_entry(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        linked_resource = "linkedResource1544625012"
        user_specified_type = "userSpecifiedType-940364963"
        user_specified_system = "userSpecifiedSystem-1776119406"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        expected_response = {
            "name": name_2,
            "linked_resource": linked_resource,
            "user_specified_type": user_specified_type,
            "user_specified_system": user_specified_system,
            "display_name": display_name,
            "description": description,
        }
        expected_response = datacatalog_pb2.Entry(**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 = datacatalog_v1beta1.DataCatalogClient()

        # Setup Request
        name = client.entry_path("[PROJECT]", "[LOCATION]", "[ENTRY_GROUP]", "[ENTRY]")

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

        assert len(channel.requests) == 1
        expected_request = datacatalog_pb2.GetEntryRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_create_entry(self):
        # Setup Expected Response
        name = "name3373707"
        linked_resource = "linkedResource1544625012"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        expected_response = {
            "name": name,
            "linked_resource": linked_resource,
            "display_name": display_name,
            "description": description,
        }
        expected_response = datacatalog_pb2.Entry(**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 = datacatalog_v1beta1.DataCatalogClient()

        # Setup Request
        parent = client.entry_group_path("[PROJECT]", "[LOCATION]",
                                         "[ENTRY_GROUP]")
        entry_id = "entryId-2093663224"
        entry = {}

        response = client.create_entry(parent, entry_id, entry)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = datacatalog_pb2.CreateEntryRequest(
            parent=parent, entry_id=entry_id, entry=entry)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request