def get_link_status(self, port): if utils.get_single_status(port) == 0: if " link is down" in ''.join(port.health.descriptions): return "DOWN" else: return "UP" return "DOWN"
def test_get_single_status_unknown(self): obj = mock.Mock() obj.health.value.value = (0, "Unknown") self.assertEqual(3, utils.get_single_status(obj))
def test_get_single_status_warning(self): obj = mock.Mock() obj.health.value.value = (10, "WARNING") self.assertEqual(1, utils.get_single_status(obj))
def test_get_single_status_critical(self): obj = mock.Mock() obj.health.value.value = (25, "CRITICAL") self.assertEqual(2, utils.get_single_status(obj))
def test_get_single_status_ok(self): obj = mock.Mock() obj.health.value.value = (5, "OK") self.assertEqual(0, utils.get_single_status(obj))