def test_get(self): """ This test will pass if it finds the correct target. """ target = Database.create_target('GET TEST') data = APIClient.get_target(self.client, 'GET TEST') self.assertEqual(data['error'], False) self.assertIsInstance(data['target'], dict) self.assertEqual(data['target']['name'], 'GET TEST') self.assertIsInstance(data['target']['mac_addrs'], list) self.assertListEqual(data['target']['mac_addrs'], target.mac_addrs)
def test_get_params(self): """ This test will pass if get returns the correct parameters. """ target = Database.create_target('PARAMS TEST') action = Database.create_action(target.name) data = APIClient.get_target(self.client, 'PARAMS TEST', False, False, True) self.assertEqual(data['error'], False) self.assertIsInstance(data['target'], dict) self.assertEqual(data['target']['name'], 'PARAMS TEST') self.assertIsInstance(data['target']['mac_addrs'], list) self.assertListEqual(data['target']['mac_addrs'], target.mac_addrs) self.assertIsNotNone(data['target']['actions']) self.assertEqual(data['target']['actions'][0]['action_id'], action.action_id) with self.assertRaises(KeyError): data['target']['sessions'] #pylint: disable=pointless-statement with self.assertRaises(KeyError): data['target']['facts'] #pylint: disable=pointless-statement