Esempio n. 1
0
 def test_rm_host(self):
     tmp = self.tmp_hosts_file(self.hostspath)
     list_hosts.hosts_filename = tmp
     rm_host.hosts_filename = tmp
     assert has_pair('127.0.0.1', 'myname')
     assert rm_host('127.0.0.1', 'myname')
     assert not has_pair('127.0.0.1', 'myname')
     assert rm_host('127.0.0.1', 'unknown')
Esempio n. 2
0
 def test_rm_host(self):
     tmp = self.tmp_hosts_file(self.hostspath)
     list_hosts.hosts_filename = tmp
     rm_host.hosts_filename = tmp
     assert has_pair('127.0.0.1', 'myname')
     assert rm_host('127.0.0.1', 'myname')
     assert not has_pair('127.0.0.1', 'myname')
     assert rm_host('127.0.0.1', 'unknown')
Esempio n. 3
0
 def test_rm_host_false(self):
     """
     Tests if specified host entry gets removed from the hosts file
     """
     with patch("salt.modules.hosts.has_pair",
                MagicMock(return_value=False)):
         self.assertTrue(hosts.rm_host("10.10.10.10", "Salt1"))
Esempio n. 4
0
 def test_rm_host_false(self):
     '''
     Tests if specified host entry gets removed from the hosts file
     '''
     with patch('salt.modules.hosts.has_pair',
                MagicMock(return_value=False)):
         self.assertTrue(hosts.rm_host('10.10.10.10', 'Salt1'))
Esempio n. 5
0
 def test_rm_host(self):
     '''
     Tests if specified host entry gets removed from the hosts file
     '''
     with patch('salt.utils.fopen', mock_open()):
         mock_opt = MagicMock(return_value=None)
         with patch.dict(hosts.__salt__, {'config.option': mock_opt}):
             self.assertTrue(hosts.rm_host('10.10.10.10', 'Salt1'))
Esempio n. 6
0
 def test_rm_host(self):
     '''
     Tests if specified host entry gets removed from the hosts file
     '''
     with patch('salt.utils.fopen', mock_open()):
         mock_opt = MagicMock(return_value=None)
         with patch.dict(hosts.__salt__, {'config.option': mock_opt}):
             self.assertTrue(hosts.rm_host('10.10.10.10', 'Salt1'))
Esempio n. 7
0
 def test_rm_host(self):
     """
     Tests if specified host entry gets removed from the hosts file
     """
     with patch("salt.utils.fopen", mock_open()):
         mock_opt = MagicMock(return_value=None)
         with patch.dict(hosts.__salt__, {"config.option": mock_opt}):
             self.assertTrue(hosts.rm_host("10.10.10.10", "Salt1"))
Esempio n. 8
0
 def test_rm_host(self):
     '''
     Tests if specified host entry gets removed from the hosts file
     '''
     with patch('salt.utils.files.fopen', mock_open()), \
             patch('salt.modules.hosts.__get_hosts_filename',
                   MagicMock(return_value='/etc/hosts')), \
             patch('salt.modules.hosts.has_pair',
                   MagicMock(return_value=True)), \
             patch('os.path.isfile', MagicMock(return_value=True)):
         mock_opt = MagicMock(return_value=None)
         with patch.dict(hosts.__salt__, {'config.option': mock_opt}):
             self.assertTrue(hosts.rm_host('10.10.10.10', 'Salt1'))
Esempio n. 9
0
 def test_rm_host(self):
     """
     Tests if specified host entry gets removed from the hosts file
     """
     with patch("salt.utils.files.fopen", mock_open(b"")), patch(
             "salt.modules.hosts.__get_hosts_filename",
             MagicMock(return_value="/etc/hosts"),
     ), patch("salt.modules.hosts.has_pair",
              MagicMock(return_value=True)), patch(
                  "os.path.isfile", MagicMock(return_value=True)):
         mock_opt = MagicMock(return_value=None)
         with patch.dict(hosts.__salt__, {"config.option": mock_opt}):
             self.assertTrue(hosts.rm_host("10.10.10.10", "Salt1"))
Esempio n. 10
0
 def test_rm_host_false(self):
     '''
     Tests if specified host entry gets removed from the hosts file
     '''
     self.assertTrue(hosts.rm_host('10.10.10.10', 'Salt1'))
Esempio n. 11
0
 def test_rm_host_false(self):
     '''
     Tests if specified host entry gets removed from the hosts file
     '''
     self.assertTrue(hosts.rm_host('10.10.10.10', 'Salt1'))
Esempio n. 12
0
 def test_rm_host_false(self):
     """
     Tests if specified host entry gets removed from the hosts file
     """
     self.assertTrue(hosts.rm_host("10.10.10.10", "Salt1"))