From c19d8f10576971e215dd86ae1dfb2f38e1914694 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Wed, 4 Oct 2023 21:56:38 +0000 Subject: [PATCH] Admin: Lakeformation: Fix test names (#6883) --- .../test_lakeformation/test_lakeformation.py | 50 ------------------- ...s.py => test_resource_tags_integration.py} | 48 ++++++++++++++++++ 2 files changed, 48 insertions(+), 50 deletions(-) rename tests/test_lakeformation/{test_resource_tags.py => test_resource_tags_integration.py} (87%) diff --git a/tests/test_lakeformation/test_lakeformation.py b/tests/test_lakeformation/test_lakeformation.py index aa60456fa..bd496734d 100644 --- a/tests/test_lakeformation/test_lakeformation.py +++ b/tests/test_lakeformation/test_lakeformation.py @@ -5,8 +5,6 @@ import pytest from botocore.exceptions import ClientError from moto import mock_lakeformation -from . import lakeformation_aws_verified - # See our Development Tips on writing tests for hints on how to write good tests: # http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html @@ -146,54 +144,6 @@ def test_revoke_permissions(): ] -@lakeformation_aws_verified -def test_lf_tags( - bucket_name=None, db_name=None, table_name=None, column_name=None -): # pylint: disable=unused-argument - client = boto3.client("lakeformation", region_name="eu-west-2") - sts = boto3.client("sts", "eu-west-2") - account_id = sts.get_caller_identity()["Account"] - - client.create_lf_tag(TagKey="tag1", TagValues=["1a", "1b", "1c"]) - client.create_lf_tag(TagKey="tag2", TagValues=["2a", "2b"]) - client.create_lf_tag(TagKey="tag3", TagValues=["3a", "3b"]) - - resp = client.get_lf_tag(TagKey="tag1") - assert resp["CatalogId"] == account_id - assert resp["TagKey"] == "tag1" - assert resp["TagValues"] == ["1a", "1b", "1c"] - - client.update_lf_tag(TagKey="tag1", TagValuesToDelete=["1a", "1c"]) - - tags = client.list_lf_tags()["LFTags"] - assert set([x["CatalogId"] for x in tags]) == {account_id} - tag_keys = [x["TagKey"] for x in tags] - assert "tag1" in tag_keys - assert "tag2" in tag_keys - assert "tag3" in tag_keys - - assert [x for x in tags if x["TagKey"] == "tag1"][0]["TagValues"] == ["1b"] - assert set([x for x in tags if x["TagKey"] == "tag2"][0]["TagValues"]) == { - "2a", - "2b", - } - assert set([x for x in tags if x["TagKey"] == "tag3"][0]["TagValues"]) == { - "3a", - "3b", - } - - client.delete_lf_tag(TagKey="tag2") - - tags = client.list_lf_tags()["LFTags"] - tag_keys = [x["TagKey"] for x in tags] - assert "tag1" in tag_keys - assert "tag3" in tag_keys - assert "tag2" not in tag_keys - - client.delete_lf_tag(TagKey="tag1") - client.delete_lf_tag(TagKey="tag3") - - @mock_lakeformation def test_list_data_cells_filter(): client = boto3.client("lakeformation", region_name="eu-west-2") diff --git a/tests/test_lakeformation/test_resource_tags.py b/tests/test_lakeformation/test_resource_tags_integration.py similarity index 87% rename from tests/test_lakeformation/test_resource_tags.py rename to tests/test_lakeformation/test_resource_tags_integration.py index 01841eb50..ecc33cc16 100644 --- a/tests/test_lakeformation/test_resource_tags.py +++ b/tests/test_lakeformation/test_resource_tags_integration.py @@ -359,3 +359,51 @@ def test_tag_lakeformation_columns( } } ) + + +@lakeformation_aws_verified +def test_lf_tags( + bucket_name=None, db_name=None, table_name=None, column_name=None +): # pylint: disable=unused-argument + client = boto3.client("lakeformation", region_name="eu-west-2") + sts = boto3.client("sts", "eu-west-2") + account_id = sts.get_caller_identity()["Account"] + + client.create_lf_tag(TagKey="tag1", TagValues=["1a", "1b", "1c"]) + client.create_lf_tag(TagKey="tag2", TagValues=["2a", "2b"]) + client.create_lf_tag(TagKey="tag3", TagValues=["3a", "3b"]) + + resp = client.get_lf_tag(TagKey="tag1") + assert resp["CatalogId"] == account_id + assert resp["TagKey"] == "tag1" + assert resp["TagValues"] == ["1a", "1b", "1c"] + + client.update_lf_tag(TagKey="tag1", TagValuesToDelete=["1a", "1c"]) + + tags = client.list_lf_tags()["LFTags"] + assert set([x["CatalogId"] for x in tags]) == {account_id} + tag_keys = [x["TagKey"] for x in tags] + assert "tag1" in tag_keys + assert "tag2" in tag_keys + assert "tag3" in tag_keys + + assert [x for x in tags if x["TagKey"] == "tag1"][0]["TagValues"] == ["1b"] + assert set([x for x in tags if x["TagKey"] == "tag2"][0]["TagValues"]) == { + "2a", + "2b", + } + assert set([x for x in tags if x["TagKey"] == "tag3"][0]["TagValues"]) == { + "3a", + "3b", + } + + client.delete_lf_tag(TagKey="tag2") + + tags = client.list_lf_tags()["LFTags"] + tag_keys = [x["TagKey"] for x in tags] + assert "tag1" in tag_keys + assert "tag3" in tag_keys + assert "tag2" not in tag_keys + + client.delete_lf_tag(TagKey="tag1") + client.delete_lf_tag(TagKey="tag3")