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]) print([str(a) for a in fixtures])
fixtures = fixtures[0:1] fixtures = fixtures[0:1]
# deactivate plugin # deactivate plugin
self.post(url, { response = self.client.post(url, {
'action': 'plugin_deactivate', 'action': 'plugin_deactivate',
'index': 0, 'index': 0,
'_selected_action': [f.pk for f in fixtures], '_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 # 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', 'action': 'plugin_deactivate',
'index': 0, 'index': 0,
'_selected_action': [f.pk for f in fixtures], '_selected_action': [f.pk for f in fixtures],
}, expected_code=200) }, follow=True)
self.assertEqual(response.status_code, 200)
# activate plugin # activate plugin
self.post(url, { response = self.client.post(url, {
'action': 'plugin_activate', 'action': 'plugin_activate',
'index': 0, 'index': 0,
'_selected_action': [f.pk for f in fixtures], '_selected_action': [f.pk for f in fixtures],
}, expected_code=200) }, follow=True)
self.assertEqual(response.status_code, 200)
# save to deactivate plugin # activate everything
self.post(reverse('admin:plugin_pluginconfig_change', {'pk': fixtures[0].pk}), { 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', '_save': 'Save',
}, expected_code=200) }, follow=True)
self.assertEqual(response.status_code, 200)