Improved node state tests

This commit is contained in:
VakarisZ 2020-03-18 09:41:07 +02:00
parent 69a4f305e5
commit a0a2311996
1 changed files with 5 additions and 11 deletions

View File

@ -6,16 +6,10 @@ from monkey_island.cc.services.utils.node_states import NodeStates, NoGroupsFoun
class TestNodeGroups(TestCase):
def test_get_group_by_keywords(self):
tst1 = NodeStates.get_by_keywords(['island']) == NodeStates.ISLAND
tst2 = NodeStates.get_by_keywords(['running', 'linux', 'monkey']) == NodeStates.MONKEY_LINUX_RUNNING
tst3 = NodeStates.get_by_keywords(['monkey', 'linux', 'running']) == NodeStates.MONKEY_LINUX_RUNNING
tst4 = False
try:
self.assertEqual(NodeStates.get_by_keywords(['island']), NodeStates.ISLAND)
self.assertEqual(NodeStates.get_by_keywords(['running', 'linux', 'monkey']), NodeStates.MONKEY_LINUX_RUNNING)
self.assertEqual(NodeStates.get_by_keywords(['monkey', 'linux', 'running']), NodeStates.MONKEY_LINUX_RUNNING)
with self.assertRaises(NoGroupsFoundException):
NodeStates.get_by_keywords(['bogus', 'values', 'from', 'long', 'list', 'should', 'fail'])
except NoGroupsFoundException:
tst4 = True
self.assertTrue(tst1)
self.assertTrue(tst2)
self.assertTrue(tst3)
self.assertTrue(tst4)