예제 #1
0
파일: tests.py 프로젝트: troelsy/pgpasslib
 def test_invalidpermissions_is_raised(self):
     with tempfile.NamedTemporaryFile(delete=False) as file_handle:
         file_handle.write(b'foo\n')
         file_name = file_handle.name
     os.environ['PGPASSFILE'] = file_name
     os.chmod(file_name,
              stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
     with self.assertRaises(pgpasslib.InvalidPermissions):
         pgpasslib._file_path()
     os.remove(file_name)
예제 #2
0
 def test_invalidpermissions_is_raised(self):
     with tempfile.NamedTemporaryFile(delete=False) as file_handle:
         file_handle.write(b'foo\n')
         file_name = file_handle.name
     os.environ['PGPASSFILE'] = file_name
     os.chmod(file_name,
              stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
     with self.assertRaises(pgpasslib.InvalidPermissions):
         pgpasslib._file_path()
     os.remove(file_name)
예제 #3
0
파일: tests.py 프로젝트: troelsy/pgpasslib
 def test_valid_permissions_return_path(self):
     with tempfile.NamedTemporaryFile(delete=False) as file_handle:
         file_handle.write(b'foo\n')
         file_name = file_handle.name
     os.environ['PGPASSFILE'] = file_name
     os.chmod(file_name, stat.S_IRUSR)
     self.assertEqual(pgpasslib._file_path(), file_name)
     os.remove(file_name)
예제 #4
0
 def test_valid_permissions_return_path(self):
     with tempfile.NamedTemporaryFile(delete=False) as file_handle:
         file_handle.write(b'foo\n')
         file_name = file_handle.name
     os.environ['PGPASSFILE'] = file_name
     os.chmod(file_name, stat.S_IRUSR)
     self.assertEqual(pgpasslib._file_path(), file_name)
     os.remove(file_name)
예제 #5
0
파일: tests.py 프로젝트: troelsy/pgpasslib
 def test_invalidpermissions_is_not_raised_on_windows(self):
     with tempfile.NamedTemporaryFile(delete=False) as file_handle:
         file_handle.write(b'foo\n')
         file_name = file_handle.name
     os.environ['PGPASSFILE'] = file_name
     os.chmod(file_name,
              stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
     with mock.patch('platform.system') as system:
         system.return_value = 'Windows'
         value = pgpasslib._file_path()
     self.assertEqual(value, file_name)
     os.remove(file_name)
예제 #6
0
 def test_invalidpermissions_is_not_raised_on_windows(self):
     with tempfile.NamedTemporaryFile(delete=False) as file_handle:
         file_handle.write(b'foo\n')
         file_name = file_handle.name
     os.environ['PGPASSFILE'] = file_name
     os.chmod(file_name,
              stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
     with mock.patch('platform.system') as system:
         system.return_value = 'Windows'
         value = pgpasslib._file_path()
     self.assertEqual(value, file_name)
     os.remove(file_name)