MCPcopy Create free account
hub / github.com/WebODM/WebODM / test_toggle_plugins

Method test_toggle_plugins

app/tests/test_plugins.py:200–231  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

198 self.assertRaises(InvalidDataStoreValue, uds.set_bool, 'invalidbool', 5)
199
200 def test_toggle_plugins(self):
201 c = Client()
202 c.login(username='testuser', password='test1234')
203
204 # Cannot toggle plugins as normal user
205 res = c.get('/admin/app/plugin/test/disable/', follow=True)
206 self.assertRedirects(res, '/admin/login/?next=/admin/app/plugin/test/disable/')
207
208 c.login(username='testsuperuser', password='test1234')
209
210 enable_plugin("test")
211
212 # Test plugin is enabled
213 res = c.get('/admin/app/plugin/')
214 self.assertContains(res, '<a class="button" href="#" disabled>Enable</a>')
215 self.assertContains(res, "<script src='/plugins/test/test.js'></script>")
216
217 # Disable
218 res = c.get('/admin/app/plugin/test/disable/', follow=True)
219 self.assertEqual(res.status_code, status.HTTP_200_OK)
220
221 # Test active vs. non-active flag for get_plugin_by_name
222 self.assertTrue(get_plugin_by_name("test") is None)
223 self.assertFalse(get_plugin_by_name("test", only_active=False) is None)
224
225 # Test plugin has been disabled
226 self.assertContains(res, '<a class="button" href="#" disabled>Disable</a>')
227 self.assertNotContains(res, "<script src='/plugins/test/test.js'></script>")
228
229 # Re-enable
230 res = c.get('/admin/app/plugin/test/enable/', follow=True)
231 self.assertEqual(res.status_code, status.HTTP_200_OK)
232
233
234 def test_plugin_functions(self):

Callers

nothing calls this directly

Calls 4

enable_pluginFunction · 0.90
get_plugin_by_nameFunction · 0.90
loginMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected