Skip to content

Commit

Permalink
fix: fix get_merged_config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zane Clark committed Oct 31, 2024
1 parent 713ae2d commit 9fec758
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/config/test_get_merged_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json
import logging
import os

import structlog
import tomlkit
from pathlib import Path
from unittest import mock
Expand Down Expand Up @@ -405,7 +407,9 @@ def test_get_merged_config_inheritance(
mock_parse_cli_args.return_value = {**cli_kwargs}
mock_get_yaml_config_kwargs.return_value = {**yaml_kwargs}
mock_get_connection_kwargs.return_value = {**connection_kwargs}
get_merged_config()
logger = structlog.testing.CapturingLogger()
# noinspection PyTypeChecker
get_merged_config(logger=logger)
factory_kwargs = mock_deploy_config_factory.call_args.kwargs
for actual_key, actual_value in factory_kwargs.items():
assert expected[actual_key] == actual_value
Expand All @@ -419,8 +423,10 @@ def test_invalid_config_folder(mock_parse_cli_args, _):
**default_cli_kwargs,
}
mock_parse_cli_args.return_value = {**cli_kwargs}
logger = structlog.testing.CapturingLogger()
with pytest.raises(Exception) as e_info:
get_merged_config()
# noinspection PyTypeChecker
get_merged_config(logger=logger)
assert f"Path is not valid directory: {cli_kwargs['config_folder']}" in str(
e_info.value
)
Expand Down Expand Up @@ -877,9 +883,11 @@ def test_integration_get_merged_config_inheritance(
cli_args,
expected,
):
logger = structlog.testing.CapturingLogger()
with mock.patch.dict(os.environ, env_vars, clear=True):
with mock.patch("sys.argv", cli_args):
get_merged_config()
# noinspection PyTypeChecker
get_merged_config(logger=logger)
factory_kwargs = mock_deploy_config_factory.call_args.kwargs
for actual_key, actual_value in factory_kwargs.items():
assert expected[actual_key] == actual_value

0 comments on commit 9fec758

Please sign in to comment.