From b6fd056d730dbd473a9321d790f31d8f74f1f302 Mon Sep 17 00:00:00 2001 From: Lova ANDRIARIMALALA <43842786+Xpirix@users.noreply.github.com> Date: Fri, 17 May 2024 14:15:56 +0300 Subject: [PATCH] Fix plugin feedback test, clear django cache before next request --- .../plugins/tests/test_plugin_version_feedback.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qgis-app/plugins/tests/test_plugin_version_feedback.py b/qgis-app/plugins/tests/test_plugin_version_feedback.py index 8f7c7702..bdf17a26 100644 --- a/qgis-app/plugins/tests/test_plugin_version_feedback.py +++ b/qgis-app/plugins/tests/test_plugin_version_feedback.py @@ -10,6 +10,7 @@ from plugins.models import Plugin, PluginVersion, PluginVersionFeedback from plugins.views import version_feedback_notify from django.conf import settings +from django.core.cache import cache class SetupMixin: fixtures = ["fixtures/auth.json", "fixtures/simplemenu.json"] @@ -150,6 +151,9 @@ def test_staff_should_see_plugin_feedback_received(self): self.assertContains(response, "test plugin 1") self.assertNotContains(response, "test plugin 2") + # Clear django cache before sending another request + cache.clear() + # add feedback for plugin 2 PluginVersionFeedback.objects.create( version=self.version_2, @@ -170,6 +174,10 @@ def test_approved_plugin_should_not_show_in_feedback_received_list(self): list(response.context['object_list']), [self.plugin_1] ) + + # Clear django cache before sending another request + cache.clear() + self.version_1.approved = True self.version_1.save() response = self.client.get(self.url) @@ -186,6 +194,10 @@ def setUp(self): super().setUp() self.url = reverse("feedback_pending_plugins") + def tearDown(self): + # Clear cache after each test + cache.clear() + def test_non_staff_should_not_see_plugin_feedback_pending_list(self): response = self.client.get(self.url) self.assertEqual(response.status_code, 404) @@ -208,6 +220,9 @@ def test_staff_should_see_plugin_feedback_pending_list(self): self.assertContains(response, "test plugin 2") self.assertNotContains(response, "test plugin 1") + # Clear django cache before sending another request + cache.clear() + # add feedback for plugin 2 PluginVersionFeedback.objects.create( version=self.version_2,