示例#1
0
 def test__runs_ping_e2e(self):
     ip = factory.make_ip_address(ipv6=False)
     # Force the use of `ping` even if `nmap` is installed.
     self.run_command('--ping', 'eth0', '%s/32' % ip)
     expected_params = PingParameters(interface='eth0', ip=ip)
     self.assertThat(self.popen, MockCalledOnceWith(
         get_ping_arguments(expected_params),
         stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL,
         stdout=subprocess.DEVNULL, env=get_env_with_locale()))
示例#2
0
 def test__runs_popen_with_expected_parameters(self):
     popen = self.patch(scan_network_module.subprocess, 'Popen')
     popen.return_value.poll = Mock()
     popen.return_value.poll.return_value = None
     popen.return_value.returncode = 0
     interface = factory.make_name('eth')
     ip = factory.make_ip_address(ipv6=False)
     params = PingParameters(interface, ip)
     run_ping(params)
     self.assertThat(popen, MockCalledOnceWith(
         get_ping_arguments(params),
         stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL,
         stdout=subprocess.DEVNULL, env=get_env_with_locale()))
示例#3
0
 def test_runs_ping_single_threaded(self):
     ip = factory.make_ip_address(ipv6=False)
     # Force the use of `ping` even if `nmap` is installed.
     self.run_command("--threads", "1", "--ping", "eth0", "%s/32" % ip)
     expected_params = PingParameters(interface="eth0", ip=ip)
     self.assertThat(
         self.popen,
         MockCalledOnceWith(
             get_ping_arguments(expected_params),
             stderr=subprocess.DEVNULL,
             stdin=subprocess.DEVNULL,
             stdout=subprocess.DEVNULL,
             env=get_env_with_locale(),
         ),
     )