MCPcopy
hub / github.com/WebODM/WebODM / test_core_plugins

Method test_core_plugins

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

Source from the content-addressed store, hash-verified

26 pass
27
28 def test_core_plugins(self):
29 client = Client()
30
31 # We cannot access public files core plugins (plugin is disabled)
32 res = client.get('/plugins/test/file.txt')
33 self.assertEqual(res.status_code, status.HTTP_404_NOT_FOUND)
34
35 # Cannot access mount point (plugin is disabled)
36 res = client.get('/plugins/test/app_mountpoint/')
37 self.assertEqual(res.status_code, status.HTTP_404_NOT_FOUND)
38
39 # No python packages have been installed (plugin is disabled)
40 self.assertFalse(os.path.exists(get_plugins_persistent_path("test", "site-packages")))
41
42 enable_plugin("test")
43
44 # Python packages have been installed
45 self.assertTrue(os.path.exists(get_plugins_persistent_path("test", "site-packages")))
46
47 # We can access public files core plugins (without auth)
48 res = client.get('/plugins/test/file.txt')
49 self.assertEqual(res.status_code, status.HTTP_200_OK)
50
51 # We mounted an endpoint
52 res = client.get('/plugins/test/app_mountpoint/')
53 self.assertEqual(res.status_code, status.HTTP_200_OK)
54 self.assertTemplateUsed(res, 'coreplugins/test/templates/app.html')
55
56 # Form was rendered correctly
57 self.assertContains(res,
58 '<input type="text" name="testField" class="form-control" required id="id_testField" />',
59 count=1, status_code=200, html=True)
60
61 # It uses regex properly
62 res = client.get('/plugins/test/app_mountpoint/a')
63 self.assertEqual(res.status_code, status.HTTP_404_NOT_FOUND)
64
65 # Querying a page should show the included CSS/JS files
66 client.login(username='testuser', password='test1234')
67 res = client.get('/dashboard/')
68 self.assertEqual(res.status_code, status.HTTP_200_OK)
69
70 self.assertContains(res, "<link href='/plugins/test/test.css' rel='stylesheet' type='text/css'>", html=True)
71 self.assertContains(res, "<script src='/plugins/test/test.js'></script>", html=True)
72
73 # And our menu entry
74 self.assertContains(res, '<li><a href="/plugins/test/menu_url/"><i class="test-icon"></i> Test</a></li>', html=True)
75
76 # A node_modules directory has been created as a result of npm install
77 # because we have a package.json in the public director
78 test_plugin = get_plugin_by_name("test")
79 self.assertTrue(os.path.exists(test_plugin.get_path("public/node_modules")))
80
81 # This is a persistent plugin
82 self.assertTrue(test_plugin.is_persistent())
83
84 # A webpack file and build directory have been created as a
85 # result of the build_jsx_components directive

Callers

nothing calls this directly

Calls 15

enable_pluginFunction · 0.90
get_plugin_by_nameFunction · 0.90
compute_file_md5Function · 0.90
requirements_installedFunction · 0.90
parse_requirementsFunction · 0.90
existsMethod · 0.80
loginMethod · 0.80
get_pathMethod · 0.80
is_persistentMethod · 0.80
python_importsMethod · 0.80

Tested by

no test coverage detected