예제 #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'
예제 #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()
예제 #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'
예제 #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')