mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
chore(tags): Allow for lookup via ids vs. name in the API (#25996)
(cherry picked from commit ee308fbc64)
This commit is contained in:
committed by
Michael S. Molina
parent
93319696de
commit
2c3bf2895f
@@ -207,6 +207,39 @@ class TestTagsDAO(SupersetTestCase):
|
||||
tagged_objects = TagDAO.get_tagged_objects_for_tags(obj_types=["chart"])
|
||||
assert len(tagged_objects) == num_charts
|
||||
|
||||
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
|
||||
@pytest.mark.usefixtures("with_tagging_system_feature")
|
||||
@pytest.mark.usefixtures("create_tags")
|
||||
# test get objects from tag
|
||||
def test_get_objects_from_tag_with_id(self):
|
||||
# create tagged objects
|
||||
dashboard = (
|
||||
db.session.query(Dashboard)
|
||||
.filter(Dashboard.dashboard_title == "World Bank's Data")
|
||||
.first()
|
||||
)
|
||||
dashboard_id = dashboard.id
|
||||
tag_1 = db.session.query(Tag).filter_by(name="example_tag_1").one()
|
||||
tag_2 = db.session.query(Tag).filter_by(name="example_tag_2").one()
|
||||
tag_ids = [tag_1.id, tag_2.id]
|
||||
self.insert_tagged_object(
|
||||
object_id=dashboard_id, object_type=ObjectType.dashboard, tag_id=tag_1.id
|
||||
)
|
||||
# get objects
|
||||
tagged_objects = TagDAO.get_tagged_objects_by_tag_id(tag_ids)
|
||||
assert len(tagged_objects) == 1
|
||||
|
||||
# test get objects from tag with type
|
||||
tagged_objects = TagDAO.get_tagged_objects_by_tag_id(
|
||||
tag_ids, obj_types=["dashboard", "chart"]
|
||||
)
|
||||
assert len(tagged_objects) == 1
|
||||
|
||||
tagged_objects = TagDAO.get_tagged_objects_by_tag_id(
|
||||
tag_ids, obj_types=["chart"]
|
||||
)
|
||||
assert len(tagged_objects) == 0
|
||||
|
||||
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
|
||||
@pytest.mark.usefixtures("with_tagging_system_feature")
|
||||
@pytest.mark.usefixtures("create_tagged_objects")
|
||||
|
||||
Reference in New Issue
Block a user