(*, ca=True, crl=False, client=False, protected=False)
| 58 | |
| 59 | @contextlib.contextmanager |
| 60 | def mock_dot_postgresql(*, ca=True, crl=False, client=False, protected=False): |
| 61 | with tempfile.TemporaryDirectory() as temp_dir: |
| 62 | home = pathlib.Path(temp_dir) |
| 63 | pg_home = home / '.postgresql' |
| 64 | pg_home.mkdir() |
| 65 | if ca: |
| 66 | shutil.copyfile(SSL_CA_CERT_FILE, pg_home / 'root.crt') |
| 67 | if crl: |
| 68 | shutil.copyfile(SSL_CA_CRL_FILE, pg_home / 'root.crl') |
| 69 | if client: |
| 70 | shutil.copyfile(CLIENT_SSL_CERT_FILE, pg_home / 'postgresql.crt') |
| 71 | if protected: |
| 72 | shutil.copyfile( |
| 73 | CLIENT_SSL_PROTECTED_KEY_FILE, pg_home / 'postgresql.key' |
| 74 | ) |
| 75 | else: |
| 76 | shutil.copyfile( |
| 77 | CLIENT_SSL_KEY_FILE, pg_home / 'postgresql.key' |
| 78 | ) |
| 79 | with unittest.mock.patch( |
| 80 | 'pathlib.Path.home', unittest.mock.Mock(return_value=home) |
| 81 | ): |
| 82 | yield |
| 83 | |
| 84 | |
| 85 | @contextlib.contextmanager |
no outgoing calls
no test coverage detected
searching dependent graphs…