Example #1
0
def test_profile_handler_prints_profile():
    shell = mock.Mock(spec=app.AWSShell)
    shell.profile = 'myprofile'
    stdout = compat.StringIO()
    handler = app.ProfileHandler(stdout)
    handler.run(['.profile'], shell)
    assert stdout.getvalue().strip() == 'Current shell profile: myprofile'
Example #2
0
def test_profile_prints_error_on_bad_syntax():
    stderr = compat.StringIO()
    handler = app.ProfileHandler(None, stderr)
    handler.run(['.profile', 'a', 'b', 'c'], None)

    # We don't really care about the exact usage message here,
    # we just want to ensure usage was written to stderr.
    assert 'Usage' in stderr.getvalue()
Example #3
0
def test_profile_command_changes_profile():
    shell = mock.Mock(spec=app.AWSShell)
    shell.profile = 'myprofile'
    stdout = compat.StringIO()
    handler = app.ProfileHandler(stdout)

    handler.run(['.profile', 'newprofile'], shell)

    assert shell.profile == 'newprofile'
Example #4
0
def test_profile_handler_when_no_profile_configured():
    shell = mock.Mock(spec=app.AWSShell)
    shell.profile = None
    stdout = compat.StringIO()
    handler = app.ProfileHandler(stdout)
    handler.run(['.profile'], shell)
    assert stdout.getvalue() == (
        'Current shell profile: no profile configured\n'
        'You can change profiles using: .profile profile-name\n')
Example #5
0
def errstream():
    return compat.StringIO()