fix tests to really hit admin actions

This commit is contained in:
Matthias 2021-11-21 22:04:22 +01:00
parent 03e5279ec0
commit c828da284c
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -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)