Admin: Lakeformation: Fix test names (#6883)

This commit is contained in:
Bert Blommers 2023-10-04 21:56:38 +00:00 committed by GitHub
parent 197e8710af
commit c19d8f1057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 50 deletions

View File

@ -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")

View File

@ -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")