예제 #1
0
 def test_parse_dnamasq(self):
     '''
     test for generic function for parsing dnsmasq files including includes.
     '''
     text_file_data = '\n'.join(["line here", "second line", "A=B", "#"])
     with patch('salt.utils.fopen',
                mock_open(read_data=text_file_data),
                create=True) as m:
         m.return_value.__iter__.return_value = text_file_data.splitlines()
         self.assertDictEqual(dnsmasq._parse_dnamasq('filename'),
                              {'A': 'B',
                               'unparsed': ['line here',
                                            'second line']})
예제 #2
0
 def test_parse_dnamasq(self):
     '''
     test for generic function for parsing dnsmasq files including includes.
     '''
     with patch('os.path.isfile', MagicMock(return_value=True)):
         text_file_data = textwrap.dedent('''\
             line here
             second line
             A=B
             #''')
         with patch('salt.utils.files.fopen',
                    mock_open(read_data=text_file_data)):
             self.assertDictEqual(
                 dnsmasq._parse_dnamasq('filename'), {
                     'A': 'B',
                     'unparsed': ['line here\n', 'second line\n']
                 })
예제 #3
0
 def test_parse_dnamasq(self):
     """
     test for generic function for parsing dnsmasq files including includes.
     """
     with patch("os.path.isfile", MagicMock(return_value=True)):
         text_file_data = textwrap.dedent("""\
             line here
             second line
             A=B
             #""")
         with patch("salt.utils.files.fopen",
                    mock_open(read_data=text_file_data)):
             self.assertDictEqual(
                 dnsmasq._parse_dnamasq("filename"),
                 {
                     "A": "B",
                     "unparsed": ["line here\n", "second line\n"]
                 },
             )