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']})
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'] })
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"] }, )