Skip to content

Commit

Permalink
Add test cases for plugin list
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix committed Nov 15, 2023
1 parent 0f61901 commit 573590b
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions qgis-app/plugins/tests/test_plugin_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from django.test import TestCase
from django.urls import reverse

class PluginsListViewTestCase(TestCase):
fixtures = [
"fixtures/styles.json",
"fixtures/auth.json",
"fixtures/simplemenu.json",
"fixtures/plugins.json",
]

def setUp(self):
pass

def test_plugins_list_view(self):
# Test the main plugins list view without any parameters
response = self.client.get(reverse('approved_plugins'))
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'plugins/plugin_list.html')
self.assertTrue('current_sort_query' in response.context)
self.assertTrue('current_querystring' in response.context)
self.assertTrue('per_page_list' in response.context)
self.assertTrue('show_more_items_number' in response.context)

def test_plugins_list_pagination(self):
# Test the plugins list view with pagination
response = self.client.get(reverse('approved_plugins'), {'per_page': 20})
self.assertEqual(response.status_code, 200)
self.assertTrue('current_sort_query' in response.context)
self.assertTrue('current_querystring' in response.context)
self.assertTrue('per_page_list' in response.context)
self.assertTrue('show_more_items_number' in response.context)

show_more_items_number = response.context['show_more_items_number']
self.assertEqual(show_more_items_number, 70)

response = self.client.get(reverse('approved_plugins'), {'per_page': show_more_items_number})
self.assertEqual(response.status_code, 200)
self.assertTrue('current_sort_query' in response.context)
self.assertTrue('current_querystring' in response.context)
self.assertTrue('per_page_list' in response.context)
self.assertTrue('show_more_items_number' in response.context)

show_more_items_number = response.context['show_more_items_number']
self.assertEqual(show_more_items_number, 120)

def test_plugins_list_sorting(self):
# Test the plugins list view with sorting
response = self.client.get(reverse('approved_plugins'), {'sort': 'name'})
self.assertEqual(response.status_code, 200)
self.assertTrue('current_sort_query' in response.context)
self.assertTrue('current_querystring' in response.context)
self.assertTrue('per_page_list' in response.context)
self.assertTrue('show_more_items_number' in response.context)

0 comments on commit 573590b

Please sign in to comment.