def test_update_pg_hba(self):
     file_contents = """some pg hba data here\n"""
     pg_hba_info = '# standby master host ip addresses\nhost\tall\tall\t192.168.2.1/32\ttrust\nhost\tall\tall\t192.168.1.1/32\ttrust\n'
     data_dirs = ['/tmp/d1', '/tmp/d2']
     expected = [file_contents + pg_hba_info, file_contents + pg_hba_info]
     m = MagicMock()
     m.return_value.__enter__.return_value.read.side_effect = [file_contents, file_contents]
     with patch('__builtin__.open', m, create=True):
         self.assertEqual(expected, update_pg_hba(pg_hba_info, data_dirs))
 def test_update_pg_hba(self):
     file_contents = """some pg hba data here\n"""
     pg_hba_info = '# standby master host ip addresses\nhost\tall\tall\t192.168.2.1/32\ttrust\nhost\tall\tall\t192.168.1.1/32\ttrust\n'
     data_dirs = ['/tmp/d1', '/tmp/d2']
     expected = [file_contents + pg_hba_info, file_contents + pg_hba_info]
     m = MagicMock()
     m.return_value.__enter__.return_value.read.side_effect = [file_contents, file_contents]
     with patch('__builtin__.open', m, create=True):
         self.assertEqual(expected, update_pg_hba(pg_hba_info, data_dirs))
Beispiel #3
0
 def test_update_pg_hba_duplicate(self):
     file_contents = """some pg hba data here\n"""
     duplicate_entry = """# standby coordinator host ip addresses\nhost\tall\tall\t192.168.2.1/32\ttrust\nhost\tall\tall\t192.168.1.1/32\ttrust\n"""
     pg_hba_info = '# standby coordinator host ip addresses\nhost\tall\tall\t192.168.2.1/32\ttrust\nhost\tall\tall\t192.168.1.1/32\ttrust\n'
     data_dirs = ['/tmp/d1', '/tmp/d2']
     expected = [file_contents + pg_hba_info]
     m = MagicMock()
     m.return_value.__enter__.return_value.read.side_effect = [
         file_contents, file_contents + duplicate_entry
     ]
     with patch('builtins.open', m, create=True):
         res = update_pg_hba(pg_hba_info, data_dirs)
         self.assertEqual(expected, res)