Exemple #1
0
 def test_quiet_add(self):
     """Add a plugin without print."""
     DEFAULT_ID = Host.objects.all()[0].hostid
     argv = ['', 'plugin', 'add', '-i', DEFAULT_ID, '-q']
     Command().run_from_argv(argv)
     # Test stdout
     out = self.stdout.getvalue()
     self.assertFalse(out, "Output is printed:\n" + out)
Exemple #2
0
 def test_list(self):
     """Get listing."""
     host = Host.objects.all()[0]
     argv = ['', 'plugin', 'list' '-i', host.hostid]
     Command().run_from_argv(argv)
     # Test stdout
     out = self.stdout.getvalue()
     self.assertTrue(out, "No output.")
Exemple #3
0
 def test_empty_list(self):
     """Get empty listing."""
     Plugin.objects.all().delete()
     argv = ['', 'plugin', 'list']
     Command().run_from_argv(argv)
     # Test stdout
     out = self.stdout.getvalue()
     self.assertTrue(out, "No output.")
Exemple #4
0
 def test_add(self):
     """Add a plugin."""
     DEFAULT_ID = Host.objects.all()[0].hostid
     HOST_PLUGINS = Host.objects.all()[0].get_plugin_list()
     argv = ['', 'plugin', 'add', '-i', DEFAULT_ID, '-p', HOST_PLUGINS[0]]
     Command().run_from_argv(argv)
     # Test creation
     new_count = Plugin.objects.count()
     self.assertGreater(new_count, 0, "Plugins wasn't created.")
Exemple #5
0
 def test_quiet_delete(self):
     """Delete a plugin without print."""
     host = Host.objects.all()[0].create_plugins()
     PLUGIN_ID = str(Plugin.objects.all()[0].id)
     argv = ['', 'plugin', 'del', '-i', PLUGIN_ID, '-q']
     Command().run_from_argv(argv)
     # Test stdout
     out = self.stdout.getvalue()
     self.assertFalse(out, "Output is printed:\n" + out)
Exemple #6
0
 def test_delete(self):
     """Delete a plugin."""
     host = Host.objects.all()[0].create_plugins()
     DEFAULT_COUNT = Plugin.objects.count()
     PLUGIN_ID = str(Plugin.objects.all()[0].id)
     argv = ['', 'plugin', 'del', '-i', PLUGIN_ID]
     Command().run_from_argv(argv)
     # Test deletion
     new_count = Plugin.objects.count()
     self.assertEqual(new_count, DEFAULT_COUNT - 1,
                      "Plugin wasn't deleted.")
Exemple #7
0
 def test_add_all(self):
     """Add an host's all plugin."""
     DEFAULT_ID = Host.objects.all()[0].hostid
     HOST_PLUGINS = Host.objects.all()[0].get_plugin_list()
     argv = ['', 'plugin', 'add', '-i', DEFAULT_ID]
     Command().run_from_argv(argv)
     # Test creation
     new_count = Plugin.objects.count()
     self.assertGreater(new_count, 0, "Plugins wasn't created.")
     self.assertEqual(new_count, len(HOST_PLUGINS),
                      "Not all plugins was created.")
Exemple #8
0
 def test_add_already_existing(self):
     """Try to add an existing plugin."""
     DEFAULT_ID = Host.objects.all()[0].hostid
     Host.objects.all()[0].create_plugins()
     DEFAULT_COUNT = Plugin.objects.count()
     argv = ['', 'plugin', 'add', '-i', DEFAULT_ID]
     Command().run_from_argv(argv)
     # Test creation
     new_count = Plugin.objects.count()
     self.assertEqual(new_count, DEFAULT_COUNT,
                      "Plugins was created again.")