def test_show_ok(self, capsys): for i in range(10): test = "test-local-{0}".format(i) arg_parser = parser.get_arguments_parser() arguments = arg_parser.parse_args(["show", test]) executor.execute_command(arguments) out, err = capsys.readouterr() assert not err assert "Name: {0}".format(test) in out assert "Mail: {0}".format(test) in out assert "Signing key: {0}".format(test) in out
def test_current_not_set(self, capsys): # Empty the configuration file with open(".test-config", "w"): pass # Check if set arg_parser = parser.get_arguments_parser() arguments = arg_parser.parse_args(["-f", "./.test-config", "current"]) executor.execute_command(arguments) out, err = capsys.readouterr() assert not err assert msg.INFO_PROFILE_NOSET in out
def test_del_profile_ok(self, capsys): arg_parser = parser.get_arguments_parser() for i in range(10): test = "test-local-{0}".format(i) arguments = arg_parser.parse_args(["del", test]) executor.execute_command(arguments) delmsg = msg.INFO_DEL_SUCCESS.format(test) out, err = capsys.readouterr() assert delmsg in out assert not err
def test_current_globally(self, capsys, prepare): arg_parser = parser.get_arguments_parser() # Set an account globally arguments = arg_parser.parse_args( ["-gf", "./.test-config", "use", "test_current_globally"]) executor.execute_command(arguments) # Check if set arguments = arg_parser.parse_args(["-gf", "./.test-config", "current"]) executor.execute_command(arguments) out, err = capsys.readouterr() assert not err assert str(prepare[2]) in out assert msg.INFO_PROFILE_CURR_GLO in out
def test_list_active(self, capsys): arg_parser = parser.get_arguments_parser() arguments = arg_parser.parse_args(["-gf", "./.test-config", "use", "test_current_globally"]) executor.execute_command(arguments) arguments = arg_parser.parse_args(["-f", "./.test-config", "use", "test_current_locally"]) executor.execute_command(arguments) arguments = arg_parser.parse_args(["-f", "./.test-config", "list"]) executor.execute_command(arguments) out, err = capsys.readouterr() assert "test_current_globally <-- active globally" in out assert "test_current_locally <-- active locally" in out assert not err
def test_no_profiles(self, capsys): fake_config = "./fake_config" with open(fake_config, "w+") as f: pass arg_parser = parser.get_arguments_parser() arguments = arg_parser.parse_args(["-f", fake_config, "list"]) executor.execute_command(arguments) out, err = capsys.readouterr() assert msg.INFO_NO_PROFILES in out try: os.remove(fake_config) except OSError: pass
def test_add_profile_quiet(self, capsys, monkeypatch): arg_parser = parser.get_arguments_parser() arguments = arg_parser.parse_args(["-q", "add", "test_add_profile_ok"]) fake_input = io.StringIO("\n".join(["test_add_profile_ok"] * 3)) monkeypatch.setattr("sys.stdin", fake_input) executor.execute_command(arguments) out, err = capsys.readouterr() success = msg.ERR_PROFILE_EXISTS.format("test_add_profile_ok") assert success not in out assert not err arguments = arg_parser.parse_args(["-q", "del", "test_add_profile_ok"]) executor.execute_command(arguments) out, err = capsys.readouterr() assert not out assert not err
def test_add_profile_ok(self, capsys, monkeypatch): arg_parser = parser.get_arguments_parser() arguments = arg_parser.parse_args(["add", "test_add_profile_ok"]) fake_input = io.StringIO("\n".join(["test_add_profile_ok"] * 3)) monkeypatch.setattr("sys.stdin", fake_input) executor.execute_command(arguments) out, err = capsys.readouterr() assert not err assert msg.BUILD_USER_INPUT in out assert msg.BUILD_MAIL_INPUT in out assert msg.BUILD_SKEY_INPUT in out success = msg.INFO_ADD_SUCCESS.format("test_add_profile_ok") assert success in out arguments = arg_parser.parse_args(["del", "test_add_profile_ok"]) executor.execute_command(arguments) out, err = capsys.readouterr() delmsg = msg.INFO_DEL_SUCCESS.format("test_add_profile_ok") assert delmsg in out assert not err
def main(): p = parser.get_arguments_parser() arguments = p.parse_args() executor.execute_command(arguments)