From 1a4365420737f373942425a01cee1138170c492d Mon Sep 17 00:00:00 2001 From: Vitor Avila <96086495+Vitor-Avila@users.noreply.github.com> Date: Mon, 13 Jan 2025 16:11:23 -0300 Subject: [PATCH] chore(tests): Changing the logic for an intermittent tag test (#31820) --- tests/integration_tests/tags/api_tests.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/integration_tests/tags/api_tests.py b/tests/integration_tests/tags/api_tests.py index c9a718f60..79022d280 100644 --- a/tests/integration_tests/tags/api_tests.py +++ b/tests/integration_tests/tags/api_tests.py @@ -487,8 +487,19 @@ class TestTagApi(SupersetTestCase): @pytest.mark.usefixtures("create_tags") def test_delete_favorite_tag_not_found(self): + """ + Tag API: Test trying to remove an unexisting tag from the list + of user favorites returns 404. + """ self.login(ADMIN_USERNAME) - uri = "api/v1/tag/123/favorites/" # noqa: F541 + + # Fetch all existing tag IDs + existing_ids = [tag_id for (tag_id,) in db.session.query(Tag.id).all()] + + # Get an ID not in use + non_existent_id = max(existing_ids, default=0) + 1 + + uri = f"api/v1/tag/{non_existent_id}/favorites/" # noqa: F541 rv = self.client.delete(uri, follow_redirects=True) assert rv.status_code == 404