Ejemplo n.º 1
0
 def test_hosts_append(self):
     with patch('salt.utils.files.fopen', mock_open(read_data=mock_hosts_file)) as m_open, \
             patch('salt.modules.dnsutil.parse_hosts', MagicMock(return_value=mock_hosts_file_rtn)):
         dnsutil.hosts_append('/etc/hosts', '127.0.0.1',
                              'ad1.yuk.co,ad2.yuk.co')
         helper_open = m_open()
         helper_open.write.assert_called_once_with(
             '\n127.0.0.1 ad1.yuk.co ad2.yuk.co')
Ejemplo n.º 2
0
 def test_hosts_append(self):
     with patch('salt.utils.fopen',
                mock_open(read_data=mock_hosts_file)) as m_open:
         dnsutil.hosts_append('/etc/hosts', '127.0.0.1',
                              'ad1.yuk.co,ad2.yuk.co')
         helper_open = m_open()
         helper_open.write.assert_called_once_with(
             '\n127.0.0.1 ad1.yuk.co ad2.yuk.co')
Ejemplo n.º 3
0
 def test_hosts_append(self):
     with patch('salt.utils.files.fopen', mock_open(read_data=mock_hosts_file)) as m_open, \
             patch('salt.modules.dnsutil.parse_hosts', MagicMock(return_value=mock_hosts_file_rtn)):
         dnsutil.hosts_append('/etc/hosts', '127.0.0.1',
                              'ad1.yuk.co,ad2.yuk.co')
         writes = m_open.write_calls()
         # We should have called .write() only once, with the expected
         # content
         num_writes = len(writes)
         assert num_writes == 1, num_writes
         expected = salt.utils.stringutils.to_str(
             '\n127.0.0.1 ad1.yuk.co ad2.yuk.co')
         assert writes[0] == expected, writes[0]
Ejemplo n.º 4
0
 def test_hosts_append(self):
     with patch('salt.utils.fopen', mock_open(read_data=mock_hosts_file)) as m_open:
         dnsutil.hosts_append('/etc/hosts', '127.0.0.1', 'ad1.yuk.co,ad2.yuk.co')
         helper_open = m_open()
         helper_open.write.assert_called_once_with('\n127.0.0.1 ad1.yuk.co ad2.yuk.co')