Exemple #1
0
 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)
Exemple #2
0
 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)
Exemple #3
0
 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())
Exemple #4
0
 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')
Exemple #5
0
 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')
Exemple #6
0
 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())
Exemple #7
0
 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())
Exemple #8
0
 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())
Exemple #9
0
 def test_list_hosts_nofile(self):
     list_hosts.hosts_filename = self.not_found
     hosts = list_hosts()
     self.assertEqual(hosts, {})
Exemple #10
0
 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'])
Exemple #11
0
 def test_list_hosts_nofile(self):
     list_hosts.hosts_filename = self.not_found
     hosts = list_hosts()
     self.assertEqual(hosts, {})
Exemple #12
0
 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'])
Exemple #13
0
 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())