Ejemplo 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')
Ejemplo 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')
Ejemplo 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"))
Ejemplo 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'))
Ejemplo 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'))
Ejemplo 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'))
Ejemplo 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"))
Ejemplo 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'))
Ejemplo 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"))
Ejemplo 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'))
Ejemplo 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'))
Ejemplo 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"))