Skip to content

Commit

Permalink
Fix plugin feedback test, clear django cache before next request
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix committed May 17, 2024
1 parent e2e73f3 commit b6fd056
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions qgis-app/plugins/tests/test_plugin_version_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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,
Expand Down

0 comments on commit b6fd056

Please sign in to comment.