def test_add_host(self): tmp = self.tmp_hosts_file(self.hostspath) list_hosts.hosts_filename = tmp add_host.hosts_filename = tmp assert add_host('192.168.1.123', 'newip') self.assertTrue(has_pair('192.168.1.123', 'newip')) self.assertEqual(len(list_hosts()), 7) assert add_host('127.0.0.1', 'othernameip') self.assertEqual(len(list_hosts()), 7)
def test_list_hosts(self): ''' Tests return the hosts found in the hosts file ''' with patch('salt.modules.hosts._list_hosts', MagicMock(return_value={'10.10.10.10': ['Salt1', 'Salt2']})): self.assertDictEqual({'10.10.10.10': ['Salt1', 'Salt2']}, hosts.list_hosts())
def test_set_host(self): tmp = self.tmp_hosts_file(self.hostspath) list_hosts.hosts_filename = tmp set_host.hosts_filename = tmp assert set_host('192.168.1.123', 'newip') self.assertTrue(has_pair('192.168.1.123', 'newip')) self.assertEqual(len(list_hosts()), 7) assert set_host('127.0.0.1', 'localhost') self.assertFalse(has_pair('127.0.0.1', 'myname'), 'should remove second entry')
def test_list_hosts(self): """ Tests return the hosts found in the hosts file """ with patch( "salt.modules.hosts._list_hosts", MagicMock(return_value={"10.10.10.10": ["Salt1", "Salt2"]}), ): self.assertDictEqual({"10.10.10.10": ["Salt1", "Salt2"]}, hosts.list_hosts())
def test_list_hosts(self): ''' Tests return the hosts found in the hosts file ''' self.assertDictEqual({'10.10.10.10': ['Salt1', 'Salt2']}, hosts.list_hosts())
def test_list_hosts_nofile(self): list_hosts.hosts_filename = self.not_found hosts = list_hosts() self.assertEqual(hosts, {})
def test_list_hosts(self): list_hosts.hosts_filename = self.hostspath hosts = list_hosts() self.assertEqual(len(hosts), 6) self.assertEqual(hosts['::1'], ['ip6-localhost', 'ip6-loopback']) self.assertEqual(hosts['127.0.0.1'], ['localhost', 'myname'])
def test_list_hosts(self): """ Tests return the hosts found in the hosts file """ self.assertDictEqual({"10.10.10.10": ["Salt1", "Salt2"]}, hosts.list_hosts())