def test_0002(self, mock_call): """ Test OK """ uuid1 = uuid.uuid1() uuid2 = uuid.uuid1() mock_call.return_value = (True, [(str(uuid1), { 'admin_ip': '192.168.1.1', 'profile': 'Server,Sensor', 'hostname': 'ascodevida' }), (str(uuid2), { 'admin_ip': '192.168.1.2', 'profile': 'Server', 'hostname': 'menzoberrazan' })]) ret = get_all() self.assertTrue(ret[0]) # Check the results res = { str(uuid1): { 'hostname': 'ascodevida', 'admin_ip': '192.168.1.1', 'profile': 'Server,Sensor' }, str(uuid2): { 'hostname': 'menzoberrazan', 'admin_ip': '192.168.1.2', 'profile': 'Server' } } for key, data in ret[1].items(): self.assertTrue(key in res.keys()) self.assertTrue(res[key] == data)
def test_0001(self, mock_call): """ Test the fail """ mock_call.return_value = False, "mock value" ret = get_all() self.assertFalse(ret[0])
def get_systems(): (success, system_data) = system.get_all() if not success: current_app.logger.error("system: get_systems error: " + str(system_data)) return make_error("Cannot retrieve systems info", 500) return make_ok(systems=system_data)
def test_0002(self, mock_call): """ Test OK """ uuid1 = uuid.uuid1() uuid2 = uuid.uuid1() mock_call.return_value = (True, [(str(uuid1), {'admin_ip': '192.168.1.1', 'profile': 'Server,Sensor', 'hostname': 'ascodevida'}), (str(uuid2), {'admin_ip': '192.168.1.2', 'profile': 'Server', 'hostname': 'menzoberrazan'}) ]) ret = get_all() self.assertTrue(ret[0]) # Check the results res = {str(uuid1): {'hostname': 'ascodevida', 'admin_ip': '192.168.1.1', 'profile': 'Server,Sensor'}, str(uuid2): {'hostname': 'menzoberrazan', 'admin_ip': '192.168.1.2', 'profile': 'Server'}} for key, data in ret[1].items(): self.assertTrue(key in res.keys()) self.assertTrue(res[key] == data)
def test_0003(self, mock_call): """ Missing data """ uuid1 = uuid.uuid1() try: mock_call.return_value = (True, [(str(uuid1), {'admin_ip': '192.168.1.1', 'profile': 'Server,Sensor'})]) _ = get_all() except KeyError: return self.assertTrue(False)
def test_0003(self, mock_call): """ Missing data """ uuid1 = uuid.uuid1() try: mock_call.return_value = (True, [(str(uuid1), { 'admin_ip': '192.168.1.1', 'profile': 'Server,Sensor' })]) _ = get_all() except KeyError: return self.assertTrue(False)