def test_dhcp_server_on_eth1(self): """Test verifies dhcp server on eth1 iface""" response = api.check_dhcp_on_eth('eth1', 2) self.assertEqual(len(response), 1) # we need to guarantee that received answer has server_ip # but dont want to check its real address self.assertTrue(response[0]['server_ip'])
def test_dhcp_server_on_eth1(self): """Test verifies dhcp server on eth1 iface """ response = api.check_dhcp_on_eth('eth1', 2) self.assertEqual(len(response), 1) # we need to guarantee that received answer has server_ip # but dont want to check its real address self.assertTrue(response[0]['server_ip'])
def test_dhcp_server_on_eth2_down(self): """iface should be ifuped in case it's down and rolledback after""" manager = utils.IfaceState([self.iface_down]) with manager as ifaces: response = api.check_dhcp_on_eth(ifaces[0], 2) self.assertEqual(len(response), 1) self.assertTrue(response[0]['server_ip']) self.assertEqual(manager.pre_iface_state, 'DOWN') self.assertEqual(manager.iface_state, 'UP') self.assertEqual(manager.post_iface_state, 'DOWN')
def test_dhcp_server_on_eth0_up(self): """Test verifies that if iface is up, it won't be touched""" manager = utils.IfaceState([self.iface_up]) with manager as ifaces: response = api.check_dhcp_on_eth(ifaces[0], 2) self.assertEqual(len(response), 1) self.assertTrue(response[0]['server_ip']) self.assertEqual(manager.pre_iface_state, 'UP') self.assertEqual(manager.iface_state, 'UP') self.assertEqual(manager.post_iface_state, 'UP')
def test_dhcp_server_on_eth0_up(self): """Test verifies that if iface is up, it won't be touched """ manager = utils.IfaceState(self.iface_up) with manager as iface: response = api.check_dhcp_on_eth(iface, 2) self.assertEqual(len(response), 1) self.assertEqual(response[0]['server_ip'], '10.0.2.2') self.assertEqual(manager.pre_iface_state, 'UP') self.assertEqual(manager.iface_state, 'UP') self.assertEqual(manager.post_iface_state, 'UP')
def test_dhcp_server_on_eth1_down(self): """Test verifies that iface would be ifuped in case it's down and rolledback after """ manager = utils.IfaceState(self.iface_down) with manager as iface: response = api.check_dhcp_on_eth(iface, 2) self.assertEqual(len(response), 1) self.assertEqual(response[0]['server_ip'], '10.10.0.8') self.assertEqual(manager.pre_iface_state, 'DOWN') self.assertEqual(manager.iface_state, 'UP') self.assertEqual(manager.post_iface_state, 'DOWN')
def test_dhcp_server_on_eth2_down(self): """Test verifies that iface would be ifuped in case it's down and rolledback after """ manager = utils.IfaceState(self.iface_down) with manager as iface: response = api.check_dhcp_on_eth(iface, 2) self.assertEqual(len(response), 1) self.assertEqual(response[0]['server_ip'], '10.10.0.8') self.assertEqual(manager.pre_iface_state, 'DOWN') self.assertEqual(manager.iface_state, 'UP') self.assertEqual(manager.post_iface_state, 'DOWN')
def test_dhcp_server_on_eth1(self): response = api.check_dhcp_on_eth('eth1', 5) self.assertEqual(len(response), 1) self.assertEqual(response[0]['server_ip'], '192.168.0.5')
def test_dhcp_server_on_eth2(self): """Test verifies dhcp server on eth2 iface """ response = api.check_dhcp_on_eth('eth2', 2) self.assertEqual(len(response), 1) self.assertEqual(response[0]['server_ip'], '10.10.0.8')
def test_dhcp_server_on_eth2(self): response = api.check_dhcp_on_eth('eth2', 5) self.assertEqual(len(response), 1) self.assertEqual(response[0]['server_ip'], '10.10.0.10')
def test_dhcp_server_on_eth1(self): """Test verifies dhcp server on eth1 iface """ response = api.check_dhcp_on_eth('eth1', 2) self.assertEqual(len(response), 1) self.assertEqual(response[0]['server_ip'], '192.168.0.5')
def test_check(): manager = utils.IfaceState('eth10') with manager as iface: api.check_dhcp_on_eth(iface, 2)
def test_check_dhcp_on_eth_empty_response(self, raw_hwaddr, srp_mock): raw_hwaddr.return_value = ('111', '222') srp_mock.return_value = ([], []) response = api.check_dhcp_on_eth('eth1', timeout=5) self.assertEqual([], response)
def test_check_dhcp_on_eth_empty_response(self, raw_hwaddr, srp_mock, *_): raw_hwaddr.return_value = ("111", "222") srp_mock.return_value = ([], []) response = api.check_dhcp_on_eth("eth1", timeout=5) self.assertEqual([], response)
def test_check(): manager = utils.IfaceState(['eth10']) with manager as ifaces: api.check_dhcp_on_eth(ifaces[0], 2)