Example #1
0
def test_get_credentials_profile_not_found_error(__init__: MagicMock,
                                                 safe_print: MagicMock,
                                                 isatty: MagicMock,
                                                 get_role_chain: MagicMock):
    __init__.return_value = None
    args = argparse.Namespace(json=None,
                              with_saml=False,
                              with_web_identity=False,
                              auto_refresh=False,
                              target_profile_name='profilename')
    profiles = {}
    obj = app.Awsume()
    obj.config = {}
    obj.plugin_manager = MagicMock()
    isatty.return_value = True
    get_role_chain.return_value = ['profilename']

    obj.plugin_manager.hook.get_credentials.side_effect = exceptions.ProfileNotFoundError(
    )
    with pytest.raises(exceptions.ProfileNotFoundError):
        obj.get_credentials(args, profiles)
    obj.plugin_manager.hook.catch_profile_not_found_exception.assert_called_with(
        config=obj.config,
        arguments=args,
        error=obj.plugin_manager.hook.get_credentials.side_effect,
        profiles=profiles)
Example #2
0
def test_profile_not_found_error_prioritize_message():
    err = exceptions.ProfileNotFoundError(profile_name='admin',
                                          message='You should see this only')
    assert str(err) == 'You should see this only'
Example #3
0
def test_profile_not_found_error():
    err = exceptions.ProfileNotFoundError(profile_name='admin')
    assert str(err) == 'Profile admin not found.'