diff options
| author | Alex Schofield <git@ajschof.me> | 2024-08-22 11:56:43 +0100 |
|---|---|---|
| committer | Alex Schofield <git@ajschof.me> | 2024-08-22 11:56:43 +0100 |
| commit | 4a3835d70bb143de23437e6f50f1050f810cd0b1 (patch) | |
| tree | 6b18abb0e2b9530b4ccb23bd374551a60cacbd11 | |
| parent | 7a66e9c46e58e58c62ec7dfe5fccbd9d826a1bf7 (diff) | |
| download | de-project-bentley-4a3835d70bb143de23437e6f50f1050f810cd0b1.tar.gz de-project-bentley-4a3835d70bb143de23437e6f50f1050f810cd0b1.zip | |
fix: inject mock_config into interface error test
| -rw-r--r-- | tests/test_extract_lambda.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/test_extract_lambda.py b/tests/test_extract_lambda.py index af3503d..ee677bd 100644 --- a/tests/test_extract_lambda.py +++ b/tests/test_extract_lambda.py @@ -17,6 +17,13 @@ from src.extract_lambda import ( retrieve_secrets, extract_bucket, ) +from pg8000.native import InterfaceError + + +@pytest.fixture(scope="function", autouse=True) +def aws_mocks(): + with mock_aws(): + yield @pytest.fixture @@ -212,12 +219,18 @@ class TestConnectToDatabase: with pytest.raises(DBConnectionException): connect_to_database() - def test_logs_interface_error(self, caplog): + def test_logs_interface_error(self, caplog, mock_config): + # Use mock_config fixture which already mocks the retrieve_secrets + # function to return JSON string with DB connection details logger = logging.getLogger() logger.info("Testing now.") caplog.set_level(logging.ERROR) - with pytest.raises(DBConnectionException): + + with patch( + "src.extract_lambda.Connection", side_effect=InterfaceError("Test error") + ), pytest.raises(DBConnectionException): connect_to_database() + assert "Interface error" in caplog.text |
