コード例 #1
0
    def test_destroy_profiles(self, capsys):
        arg_parser = parser.get_arguments_parser()
        arguments = arg_parser.parse_args(["-f", "./.test-config", "destroy"])
        executor.execute_command(arguments)

        out, err = capsys.readouterr()
        assert not err
        assert msg.INFO_DESTROY_SUCCESS.format(10) in out
コード例 #2
0
    def test_use_not_exist(self, capsys):
        arg_parser = parser.get_arguments_parser()

        # Set an account locally
        fake_profile = "profile-{0}".format(randrange(100000))
        arguments = arg_parser.parse_args(["use", fake_profile])
        executor.execute_command(arguments)

        out, err = capsys.readouterr()
        assert not err
        assert msg.ERR_NO_PROFILE.format(fake_profile) in out
コード例 #3
0
    def test_del_profile_not_found(self, capsys):
        test = "profile-{0}".format(randrange(100000))
        arg_parser = parser.get_arguments_parser()
        arguments = arg_parser.parse_args(["del", test])
        executor.execute_command(arguments)

        out, err = capsys.readouterr()
        delmsg = msg.ERR_NO_PROFILE.format(test)

        assert delmsg in out
        assert not err
コード例 #4
0
    def test_update_profile_ok(self, capsys, monkeypatch):
        arg_parser = parser.get_arguments_parser()
        arguments = arg_parser.parse_args(["update", "test-update-profile"])

        fake_input = io.StringIO("\n".join(["something-else"] * 3))
        monkeypatch.setattr("sys.stdin", fake_input)
        executor.execute_command(arguments)
        out, err = capsys.readouterr()

        assert msg.INFO_UPD_SUCCESS.format("test-update-profile") in out
        assert not err
コード例 #5
0
    def test_list_profiles(self, capsys):
        arg_parser = parser.get_arguments_parser()
        arguments = arg_parser.parse_args(["-f", "./.test-config", "list"])
        executor.execute_command(arguments)

        out, err = capsys.readouterr()
        assert msg.INFO_AVAIL_PROFILES in out

        for i in range(10):
            test = "test-local-{0}".format(i)
            assert test in out
コード例 #6
0
    def test_add_profile_no_param(self, capsys, monkeypatch):
        arg_parser = parser.get_arguments_parser()
        arguments = arg_parser.parse_args(["add", "test_add_profile_ok"])

        fake_input = ["\n", "\n", "\n", "x", "x", "x"]
        monkeypatch.setattr("sys.stdin", io.StringIO("\n".join(fake_input)))
        executor.execute_command(arguments)

        out, err = capsys.readouterr()
        assert msg.BUILD_REQUIRED in out
        assert not err
コード例 #7
0
    def test_show_exists(self, capsys):
        arg_parser = parser.get_arguments_parser()
        fake_profile = "profile-{0}".format(randrange(100000))

        arguments = arg_parser.parse_args(["show", fake_profile])
        executor.execute_command(arguments)

        out, err = capsys.readouterr()
        fail_mesg = msg.ERR_NO_PROFILE.format(fake_profile)

        assert fail_mesg in out
        assert not err
コード例 #8
0
    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
コード例 #9
0
    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
コード例 #10
0
    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
コード例 #11
0
    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
コード例 #12
0
    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
コード例 #13
0
    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
コード例 #14
0
    def test_add_profile_exists(self, capsys, monkeypatch):
        # Add a test profile
        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)

        # Try to add it again
        arguments = arg_parser.parse_args(["add", "test_add_profile_ok"])
        executor.execute_command(arguments)

        # Check if the error message was displayed
        out, err = capsys.readouterr()
        errmsg = msg.ERR_PROFILE_EXISTS.format("test_add_profile_ok")
        assert errmsg in out
        assert not err

        # Delete the test profile
        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
コード例 #15
0
    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
コード例 #16
0
    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
コード例 #17
0
def main():
    p = parser.get_arguments_parser()
    arguments = p.parse_args()
    executor.execute_command(arguments)