From c828da284ce390436e823e286f51fc8cb2ea9790 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 21 Nov 2021 22:04:22 +0100 Subject: [PATCH] fix tests to really hit admin actions --- InvenTree/plugin/test_api.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/InvenTree/plugin/test_api.py b/InvenTree/plugin/test_api.py index a03427dc2b..a469bfa31e 100644 --- a/InvenTree/plugin/test_api.py +++ b/InvenTree/plugin/test_api.py @@ -77,27 +77,41 @@ class PluginDetailAPITest(InvenTreeAPITestCase): print([str(a) for a in fixtures]) fixtures = fixtures[0:1] # deactivate plugin - self.post(url, { + response = self.client.post(url, { 'action': 'plugin_deactivate', 'index': 0, '_selected_action': [f.pk for f in fixtures], - }, expected_code=200) + }, follow=True) + self.assertEqual(response.status_code, 200) # deactivate plugin - deactivate again -> nothing will hapen but the nothing 'changed' function is triggered - self.post(url, { + response = self.client.post(url, { 'action': 'plugin_deactivate', 'index': 0, '_selected_action': [f.pk for f in fixtures], - }, expected_code=200) + }, follow=True) + self.assertEqual(response.status_code, 200) # activate plugin - self.post(url, { + response = self.client.post(url, { 'action': 'plugin_activate', 'index': 0, '_selected_action': [f.pk for f in fixtures], - }, expected_code=200) + }, follow=True) + self.assertEqual(response.status_code, 200) - # save to deactivate plugin - self.post(reverse('admin:plugin_pluginconfig_change', {'pk': fixtures[0].pk}), { + # activate everything + fixtures = PluginConfig.objects.all() + response = self.client.post(url, { + 'action': 'plugin_activate', + 'index': 0, + '_selected_action': [f.pk for f in fixtures], + }, follow=True) + self.assertEqual(response.status_code, 200) + + fixtures = PluginConfig.objects.filter(active=True) + # save to deactivate a plugin + response = self.client.post(reverse('admin:plugin_pluginconfig_change', args=(fixtures.first().pk, )), { '_save': 'Save', - }, expected_code=200) + }, follow=True) + self.assertEqual(response.status_code, 200)