def testList(self, capsys, sort_key, group_format):
        self.args += ["list"]
        if sort_key:
            self.args += ["--sort-by-%s" % sort_key]
        if group_format:
            self.args += ["--%s" % group_format]
        self.cli.invoke(self.args, strict=True)

        # Read from the stdout
        out, err = capsys.readouterr()
        ids = get_user_ids(out, sort_key=sort_key)

        # Check all users are listed
        if sort_key == 'login':
            sorted_list = sorted(self.users, key=lambda x: x.omeName.val)
        elif sort_key == 'first-name':
            sorted_list = sorted(self.users, key=lambda x: x.firstName.val)
        elif sort_key == 'last-name':
            sorted_list = sorted(self.users, key=lambda x: x.lastName.val)
        elif sort_key == 'email':
            sorted_list = sorted(self.users, key=lambda x: (
                x.email and x.email.val or ""))
        else:
            sorted_list = sorted(self.users, key=lambda x: x.id.val)
        assert ids == [user.id.val for user in sorted_list]
    def testListUsersNoArgument(self, capsys):
        self.args += ["listusers"]
        self.cli.invoke(self.args, strict=True)

        out, err = capsys.readouterr()
        ids = get_user_ids(out)
        assert ids == [self.user.id.val]
    def testInfoNoArgument(self, capsys):
        self.args += ["info"]
        self.cli.invoke(self.args, strict=True)

        # Read from the stdout
        out, err = capsys.readouterr()
        ids = get_user_ids(out)
        assert ids == [self.user.id.val]
    def testListUsersArgument(self, capsys, groupfixture):
        self.args += ["listusers"]
        self.args += groupfixture.get_arguments(self.group)
        self.cli.invoke(self.args, strict=True)

        out, err = capsys.readouterr()
        ids = get_user_ids(out)
        assert ids == [self.user.id.val]
Beispiel #5
0
    def testListUsersArgument(self, capsys, groupfixture):
        self.args += ["listusers"]
        self.args += groupfixture.get_arguments(self.group)
        self.cli.invoke(self.args, strict=True)

        out, err = capsys.readouterr()
        ids = get_user_ids(out)
        assert ids == [self.user.id.val]
Beispiel #6
0
    def testInfoArgument(self, capsys, userfixture):
        self.args += ["info"]
        self.args += userfixture.get_arguments(self.user)
        self.cli.invoke(self.args, strict=True)

        # Read from the stdout
        out, err = capsys.readouterr()
        ids = get_user_ids(out)
        assert ids == [self.user.id.val]