def test_hosts_remove(self): to_remove = 'ad1.yuk.co' new_mock_file = mock_hosts_file + '\n127.0.0.1 ' + to_remove + '\n' with patch('salt.utils.files.fopen', mock_open(read_data=new_mock_file)) as m_open: dnsutil.hosts_remove('/etc/hosts', to_remove) writes = m_open.write_calls() assert writes == mock_writes_list, writes
def test_hosts_remove(self): to_remove = 'ad1.yuk.co' new_mock_file = mock_hosts_file + '\n127.0.0.1 ' + to_remove + '\n' with patch('salt.utils.fopen', mock_open(read_data=new_mock_file)) as m_open: dnsutil.hosts_remove('/etc/hosts', to_remove) helper_open = m_open() calls_list = helper_open.method_calls self.assertEqual(calls_list, mock_calls_list)
def test_hosts_remove(self): to_remove = "ad1.yuk.co" new_mock_file = mock_hosts_file + "\n127.0.0.1 " + to_remove + "\n" with patch( "salt.utils.files.fopen", mock_open(read_data=new_mock_file) ) as m_open: dnsutil.hosts_remove("/etc/hosts", to_remove) writes = m_open.write_calls() assert writes == mock_writes_list, writes