fix(tagging): adding tags containing a “:” to dashboards (#26324)

will add more tests in a separated PR
This commit is contained in:
Lily Kuang
2023-12-22 10:30:08 -08:00
committed by GitHub
parent 5400d30b20
commit 3391e29093
4 changed files with 17 additions and 30 deletions

View File

@@ -124,13 +124,19 @@ class TestTagsDAO(SupersetTestCase):
@pytest.mark.usefixtures("with_tagging_system_feature")
# test create tag
def test_create_tagged_objects(self):
# test that a tag cannot be added if it has ':' in it
with pytest.raises(DAOCreateFailedError):
TagDAO.create_custom_tagged_objects(
object_type=ObjectType.dashboard.name,
object_id=1,
tag_names=["invalid:example tag 1"],
)
# test that a tag can be added if it has ':' in it
TagDAO.create_custom_tagged_objects(
object_type=ObjectType.dashboard.name,
object_id=1,
tag_names=["valid:example tag 1"],
)
# test that a tag can be added if it has ',' in it
TagDAO.create_custom_tagged_objects(
object_type=ObjectType.dashboard.name,
object_id=1,
tag_names=["example,tag,1"],
)
# test that a tag can be added if it has a valid name
TagDAO.create_custom_tagged_objects(
@@ -320,11 +326,3 @@ class TestTagsDAO(SupersetTestCase):
.first()
)
assert tagged_object is None
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
@pytest.mark.usefixtures("with_tagging_system_feature")
def test_validate_tag_name(self):
assert TagDAO.validate_tag_name("example_tag_name") is True
assert TagDAO.validate_tag_name("invalid:tag_name") is False
db.session.query(TaggedObject).delete()
db.session.query(Tag).delete()