示例#1
0
def test_validate_default_profile_prints_create_profile_help_when_no_valid_default_and_no_other_profiles_exists(
        capsys, config_accessor):
    config_accessor.get_profile.side_effect = NoConfigProfileError()
    config_accessor.get_all_profiles.return_value = []
    with pytest.raises(Code42CLIError):
        cliprofile.validate_default_profile()
        capture = capsys.readouterr()
        assert "No existing profile." in capture.out
示例#2
0
def test_validate_default_profile_prints_set_default_help_when_no_valid_default_but_another_profile_exists(
    capsys, config_accessor
):
    config_accessor.get_profile.side_effect = NoConfigProfileError()
    config_accessor.get_all_profiles.return_value = [MockSection("thisprofilexists")]
    with pytest.raises(Code42CLIError):
        cliprofile.validate_default_profile()
        capture = capsys.readouterr()
        assert "No default profile set." in capture.out
示例#3
0
def test_create_profile_uses_expected_profile_values(config_accessor):
    config_accessor.get_profile.side_effect = NoConfigProfileError()
    profile_name = "profilename"
    server = "server"
    username = "******"
    ssl_errors_disabled = True
    cliprofile.create_profile(profile_name, server, username,
                              ssl_errors_disabled)
    config_accessor.create_profile.assert_called_once_with(
        profile_name, server, username, ssl_errors_disabled)
示例#4
0
def test_get_profile_when_config_accessor_raises_cli_error(config_accessor):
    config_accessor.get_profile.side_effect = NoConfigProfileError()
    with pytest.raises(Code42CLIError):
        cliprofile.get_profile("testprofilename")
示例#5
0
def test_profile_exists_when_not_exists_returns_false(config_accessor):
    config_accessor.get_profile.side_effect = NoConfigProfileError()
    assert not cliprofile.profile_exists("idontexist")