Skip to content

Commit

Permalink
update unit test
Browse files Browse the repository at this point in the history
Signed-off-by: pem70 <[email protected]>
  • Loading branch information
pem70 committed May 28, 2024
1 parent c99b0b0 commit d6c6c31
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/unit/test_zowe_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def test_profile_empty_exception(self, get_pass_func, mock_logger_error: mock.Ma
self.setUpCreds(cwd_up_file_path, secure_props={})
config_file = ConfigFile(name=self.custom_appname, type="team_config")
props: dict = config_file.get_profile(profile_name=None,profile_type=None,validate_schema=False)
self.assertEqual(mock_logger_error.call_args[0][0], "Failed to load profile 'None' because Could not find profile as both profile_name and profile_type is not set")
self.assertEqual(mock_logger_error.call_args[0][0], "Failed to load profile 'None' because Could not find profile as both profile_name and profile_type is not set")

@mock.patch("logging.Logger.error")
@mock.patch("logging.Logger.warning")
Expand All @@ -470,11 +470,13 @@ def test_get_profilename_from_profiletype_invalid_profile_type(self, get_pass_fu
"""
with self.assertRaises(exceptions.ProfileNotFound):
config_file = ConfigFile(name=self.custom_appname, type="team_config", defaults={}, profiles={'a': {'type' : 'none'}})
config_file.get_profilename_from_profiletype('test')
self.assertEqual(mock_logger_warning.call_args[0][0], "Given profile type 'test' has no default profile name")
self.assertEqual(mock_logger_warning.call_args[1][0], "Profile 'a' has no type attribute")
self.assertEqual(mock_logger_error.call_args[0][0], "No profile with matching profile_type 'test' found")
config_file = ConfigFile(name="name", type="team_config", defaults={}, profiles={'a': {'none' : 'none'}})
config_file.get_profilename_from_profiletype('test')

mock_logger_warning.assert_any_call("Given profile type 'test' has no default profile name")
mock_logger_warning.assert_any_call("Profile 'a' has no type attribute")
mock_logger_error.assert_called_once_with("No profile with matching profile_type 'test' found")


@mock.patch("logging.Logger.warning")
@mock.patch("zowe.secrets_for_zowe_sdk.keyring.get_password", side_effect=keyring_get_password)
Expand All @@ -485,7 +487,7 @@ def test_validate_schema(self, get_pass_func, mock_logger_warning: mock.MagicMoc
Schema property will be initialized to None.
"""
with self.assertWarns(UserWarning):
config_file = ConfigFile(name=self.custom_appname, type="team_config")
config_file = ConfigFile(name="name", type="team_config")
config_file.validate_schema()
self.assertEqual(mock_logger_warning.call_args[0][0], "Could not find $schema property")

Expand Down

0 comments on commit d6c6c31

Please sign in to comment.