No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_plugin.py 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #-*- coding: utf-8 -*-
  2. import unittest
  3. from lodel.plugin.plugins import Plugin, PluginError
  4. from lodel.settings.settings import Settings
  5. import tests.loader_utils
  6. class PluginTestCase(unittest.TestCase):
  7. def test_plugin_init_right_name(self):
  8. Plugin.start(['/home/helene/lodel2/plugins'],['dummy'])
  9. Plugin.clear()
  10. # With a wrong plugin name, a NameError Exception has to be raised at line 318 of plugin.py
  11. def test_plugin_init_wrong_name(self):
  12. with self.assertRaises(NameError):
  13. Plugin.start(['/home/helene/lodel2/plugins', '/home/helene/lodel2/tests/tests_plugins' ],['wrong_plugin_name'])
  14. Plugin.clear()
  15. # With a wrong plugin name, a NameError Exception has to be raised at line 318 of plugin.py
  16. def test_plugin_init_right_wrong_name(self):
  17. with self.assertRaises(NameError):
  18. Plugin.start(['/home/helene/lodel2/plugins', '/home/helene/lodel2/tests/tests_plugins'],['dummy', 'wrong_plugin_name'])
  19. Plugin.clear()
  20. def test_plugin_started(self):
  21. with self.assertRaises(RuntimeError):
  22. Plugin.started()
  23. def test_plugin_plugin_path(self):
  24. Plugin.start(['/home/helene/lodel2/plugins', '/home/helene/lodel2/tests/tests_plugins'],['dummy'])
  25. self.assertEqual(Plugin.plugin_path('dummy'), '/home/helene/lodel2/plugins/dummy/')
  26. Plugin.clear()
  27. def test_plugin_get(self):
  28. Plugin.start(['/home/helene/lodel2/plugins', '/home/helene/lodel2/tests/tests_plugins'],['dummy'])
  29. with self.assertRaises(PluginError):
  30. Plugin.get('wrong_plugin_name')
  31. self.assertTrue(isinstance(Plugin.get('dummy'), Plugin))
  32. Plugin.clear()
  33. def test_plugin_register(self):
  34. with self.assertRaises(RuntimeError):
  35. Plugin.register('dummy')
  36. Plugin.start(['/home/helene/lodel2/plugins'],['dummy'])
  37. with self.assertRaises(PluginError):
  38. Plugin.register('dummy')
  39. Plugin.clear()
  40. def test_plugin_load_all(self):
  41. #Plugin.start(['/home/helene/lodel2/plugins'],['dummynotactivable'])
  42. #Plugin.load_all()
  43. pass