[LYN-2151] Add argument to override aws profile and config file path (#994)
This commit is contained in:
+27
-1
@@ -43,7 +43,7 @@ class TestConfigurationManager(TestCase):
|
||||
mock_find_files_with_suffix_under_directory: MagicMock,
|
||||
mock_get_default_account_id: MagicMock,
|
||||
mock_get_default_region: MagicMock) -> None:
|
||||
TestConfigurationManager._expected_configuration_manager.setup()
|
||||
TestConfigurationManager._expected_configuration_manager.setup("")
|
||||
mock_get_current_directory_path.assert_called_once()
|
||||
mock_check_path_exists.assert_called_once_with(TestConfigurationManager._expected_directory_path)
|
||||
mock_find_files_with_suffix_under_directory.assert_called_once_with(
|
||||
@@ -58,3 +58,29 @@ class TestConfigurationManager(TestCase):
|
||||
TestConfigurationManager._expected_account_id
|
||||
assert TestConfigurationManager._expected_configuration_manager.configuration.region == \
|
||||
TestConfigurationManager._expected_region
|
||||
|
||||
@patch("utils.aws_utils.get_default_region", return_value=_expected_region)
|
||||
@patch("utils.aws_utils.get_default_account_id", return_value=_expected_account_id)
|
||||
@patch("utils.file_utils.find_files_with_suffix_under_directory", return_value=_expected_config_files)
|
||||
@patch("utils.file_utils.check_path_exists", return_value=True)
|
||||
@patch("utils.file_utils.normalize_file_path", return_value=_expected_directory_path)
|
||||
def test_setup_get_configuration_setup_with_path_as_expected(self, mock_normalize_file_path: MagicMock,
|
||||
mock_check_path_exists: MagicMock,
|
||||
mock_find_files_with_suffix_under_directory: MagicMock,
|
||||
mock_get_default_account_id: MagicMock,
|
||||
mock_get_default_region: MagicMock) -> None:
|
||||
TestConfigurationManager._expected_configuration_manager.setup(TestConfigurationManager._expected_directory_path)
|
||||
mock_normalize_file_path.assert_called_once()
|
||||
mock_check_path_exists.assert_called_once_with(TestConfigurationManager._expected_directory_path)
|
||||
mock_find_files_with_suffix_under_directory.assert_called_once_with(
|
||||
TestConfigurationManager._expected_directory_path, constants.RESOURCE_MAPPING_CONFIG_FILE_NAME_SUFFIX)
|
||||
mock_get_default_account_id.assert_called_once()
|
||||
mock_get_default_region.assert_called_once()
|
||||
assert TestConfigurationManager._expected_configuration_manager.configuration.config_directory == \
|
||||
TestConfigurationManager._expected_directory_path
|
||||
assert TestConfigurationManager._expected_configuration_manager.configuration.config_files == \
|
||||
TestConfigurationManager._expected_config_files
|
||||
assert TestConfigurationManager._expected_configuration_manager.configuration.account_id == \
|
||||
TestConfigurationManager._expected_account_id
|
||||
assert TestConfigurationManager._expected_configuration_manager.configuration.region == \
|
||||
TestConfigurationManager._expected_region
|
||||
|
||||
@@ -36,7 +36,7 @@ class TestViewManager(TestCase):
|
||||
|
||||
main_window_patcher: patch = patch("manager.view_manager.QMainWindow")
|
||||
cls._mock_main_window = main_window_patcher.start()
|
||||
window_icon_patcher: patch = patch("manager.view_manager.QPixmap")
|
||||
window_icon_patcher: patch = patch("manager.view_manager.QIcon")
|
||||
window_icon_patcher.start()
|
||||
|
||||
stacked_pages_patcher: patch = patch("manager.view_manager.QStackedWidget")
|
||||
|
||||
@@ -37,13 +37,12 @@ class TestAWSUtils(TestCase):
|
||||
.build()
|
||||
|
||||
def setUp(self) -> None:
|
||||
client_patcher: patch = patch("boto3.client")
|
||||
self.addCleanup(client_patcher.stop)
|
||||
self._mock_client: MagicMock = client_patcher.start()
|
||||
|
||||
session_patcher: patch = patch("boto3.session.Session")
|
||||
self.addCleanup(session_patcher.stop)
|
||||
self._mock_session: MagicMock = session_patcher.start()
|
||||
self._mock_client: MagicMock = self._mock_session.return_value.client
|
||||
|
||||
aws_utils.setup_default_session("default")
|
||||
|
||||
def test_get_default_account_id_return_expected_account_id(self) -> None:
|
||||
mocked_sts_client: MagicMock = self._mock_client.return_value
|
||||
|
||||
Reference in New Issue
Block a user