def test_probe_interface_returns_empty_set_when_nothing_detected(self): eth0_addr = factory.getRandomIPAddress() self.patch_fake_interfaces_list([("eth0", eth0_addr)]) self.patch(detect_module, 'probe_dhcp').return_value = set() interfaces = determine_cluster_interfaces(self.knowledge) results = probe_interface(*interfaces[0]) self.assertEqual(set(), results)
def test_probe_interface_returns_populated_set(self): # Test that the detected DHCP server is returned. eth0_addr = factory.getRandomIPAddress() self.patch_fake_interfaces_list([("eth0", eth0_addr)]) self.patch(detect_module, 'probe_dhcp').return_value = {'10.2.2.2'} interfaces = determine_cluster_interfaces(self.knowledge) results = probe_interface(*interfaces[0]) self.assertEqual({'10.2.2.2'}, results)
def test__run_via_probe_interface_returns_servers(self): mock_send_and_await = self.patch(DHCPRequestMonitor, "send_requests_and_await_replies") mock_send_and_await.return_value = { DHCPServer("127.0.0.1", "127.0.0.1"), DHCPServer("127.1.1.1", "127.2.2.2"), } result = yield probe_interface("lo") self.assertThat(mock_send_and_await, MockCallsMatch(call())) self.assertThat(result, Equals({"127.0.0.1", "127.1.1.1"}))
def test_probe_interface_filters_interface_own_ip(self): # Test that the interface shows the detected DHCP server except # if it is the same IP as the interface's. eth0_addr = factory.getRandomIPAddress() self.patch_fake_interfaces_list([("eth0", eth0_addr)]) detected_dhcp = eth0_addr self.patch(detect_module, 'probe_dhcp').return_value = {detected_dhcp} interfaces = determine_cluster_interfaces(self.knowledge) results = probe_interface(*interfaces[0]) self.assertEqual(set(), results)