"""Test configuration. This file gets picked up when running py.test tests: http://pytest.org/latest/writing_plugins.html#conftest """ from unittest.mock import patch from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization import pytest from dbdeploy.base import config @pytest.fixture def mock_base_config(): key = rsa.generate_private_key( backend=default_backend(), public_exponent=65537, key_size=2048 ) test_private_key = key.private_bytes( encoding=serialization.Encoding.PEM, format=serialization.PrivateFormat.PKCS8, encryption_algorithm=serialization.BestAvailableEncryption(b'test_passphrase') # noqa: E501 ).decode("utf-8") test_private_key_string = ''.join(test_private_key.split('\n')[1:-2]) config.SNOWFLAKE_ROLE = 'test_role' config.SNOWFLAKE_WAREHOUSE = 'test_warehouse' config.SNOWFLAKE_DATABASE = 'test_database' config.SNOWFLAKE_SCHEMA = 'test_schema' config.SNOWFLAKE_ACCOUNTS['orchard'].SNOWFLAKE_USER = 'test_user' config.SNOWFLAKE_ACCOUNTS['orchard'].SNOWFLAKE_ACCOUNT = 'test_account' config.SNOWFLAKE_ACCOUNTS['orchard'].SNOWFLAKE_PRIVATE_KEY_STRING = test_private_key_string config.SNOWFLAKE_ACCOUNTS['orchard'].SNOWFLAKE_KEY_PASSPHRASE = 'test_passphrase' @pytest.fixture def mock_get_secret(): """Mock get secret.""" path = 'secrets_manager.python_ext.PythonSecretsManager.get_secret' with patch(path) as get_secret: yield get_secret