def test_create_host_splitting(self) -> None:
     parser = configparser.ConfigParser()
     parser.read_string(
         """
         [section]
         hosts=a,b,c
         """
     )
     ping = Ping.create("name", parser["section"])
     assert ping._hosts == ["a", "b", "c"]
    def test_smoke(self, mocker) -> None:
        mock = mocker.patch("subprocess.call")
        mock.return_value = 1

        hosts = ["abc", "129.123.145.42"]

        assert Ping("name", hosts).check() is None

        assert mock.call_count == len(hosts)
        for (args, _), host in zip(mock.call_args_list, hosts):
            assert args[0][-1] == host
    def test_smoke(self, mocker):
        mock = mocker.patch('subprocess.call')
        mock.return_value = 1

        hosts = ['abc', '129.123.145.42']

        assert Ping('name', hosts).check() is None

        assert mock.call_count == len(hosts)
        for (args, _), host in zip(mock.call_args_list, hosts):
            assert args[0][-1] == host
 def test_create_missing_hosts(self) -> None:
     parser = configparser.ConfigParser()
     parser.read_string("""[section]""")
     with pytest.raises(ConfigurationError):
         Ping.create("name", parser["section"])
 def test_matching(self, mocker) -> None:
     mock = mocker.patch("subprocess.call")
     mock.return_value = 0
     assert Ping("name", ["foo"]).check() is not None
 def create_instance(self, name):
     return Ping(name, "8.8.8.8")
 def test_create_host_splitting(self):
     parser = configparser.ConfigParser()
     parser.read_string('''[section]
                        hosts=a,b,c''')
     ping = Ping.create('name', parser['section'])
     assert ping._hosts == ['a', 'b', 'c']
 def test_create_missing_hosts(self):
     parser = configparser.ConfigParser()
     parser.read_string('''[section]''')
     with pytest.raises(ConfigurationError):
         Ping.create('name', parser['section'])
 def test_matching(self, mocker):
     mock = mocker.patch('subprocess.call')
     mock.return_value = 0
     assert Ping('name', ['foo']).check() is not None