def test_ping(self): a1 = set_pea_parser().parse_args([]) a2 = set_ping_parser().parse_args(['0.0.0.0', str(a1.port_ctrl), '--print-response']) a3 = set_ping_parser().parse_args(['0.0.0.1', str(a1.port_ctrl), '--timeout', '1000']) with self.assertRaises(SystemExit) as cm: with BasePea(a1): NetworkChecker(a2) self.assertEqual(cm.exception.code, 0) # test with bad addresss with self.assertRaises(SystemExit) as cm: with BasePea(a1): NetworkChecker(a3) self.assertEqual(cm.exception.code, 1)
def test_ping(): a1 = set_pea_parser().parse_args([]) a2 = set_ping_parser().parse_args(['0.0.0.0', str(a1.port_ctrl), '--print-response']) a3 = set_ping_parser().parse_args(['0.0.0.1', str(a1.port_ctrl), '--timeout', '1000']) with pytest.raises(SystemExit) as cm: with BasePea(a1): NetworkChecker(a2) assert cm.value.code == 0 # test with bad addresss with pytest.raises(SystemExit) as cm: with BasePea(a1): NetworkChecker(a3) assert cm.value.code == 1
def test_container_ping(self): a4 = set_pea_parser().parse_args(['--image', img_name]) a5 = set_ping_parser().parse_args(['0.0.0.0', str(a4.port_ctrl), '--print-response']) # test with container with self.assertRaises(SystemExit) as cm: with BasePea(a4): NetworkChecker(a5) self.assertEqual(cm.exception.code, 0)