def test_get_tag_template(self): # Setup Expected Response name_2 = "name2-1052831874" display_name = "displayName1615086568" expected_response = {"name": name_2, "display_name": display_name} expected_response = tags_pb2.TagTemplate(**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.tag_template_path("[PROJECT]", "[LOCATION]", "[TAG_TEMPLATE]") response = client.get_tag_template(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = datacatalog_pb2.GetTagTemplateRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_tag_template(self): # Setup Expected Response name = "name3373707" display_name = "displayName1615086568" expected_response = {"name": name, "display_name": display_name} expected_response = tags_pb2.TagTemplate(**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 tag_template = {} response = client.update_tag_template(tag_template) assert expected_response == response assert len(channel.requests) == 1 expected_request = datacatalog_pb2.UpdateTagTemplateRequest( tag_template=tag_template) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_tag_template(self): # Setup Expected Response name = "name3373707" display_name = "displayName1615086568" expected_response = {"name": name, "display_name": display_name} expected_response = tags_pb2.TagTemplate(**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.location_path("[PROJECT]", "[LOCATION]") tag_template_id = "tagTemplateId-2020335141" tag_template = {} response = client.create_tag_template(parent, tag_template_id, tag_template) assert expected_response == response assert len(channel.requests) == 1 expected_request = datacatalog_pb2.CreateTagTemplateRequest( parent=parent, tag_template_id=tag_template_id, tag_template=tag_template) actual_request = channel.requests[0][1] assert expected_request == actual_request