Ejemplo n.º 1
0
    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]
Ejemplo n.º 2
0
    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]
Ejemplo n.º 3
0
    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]
Ejemplo n.º 4
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]
Ejemplo n.º 5
0
    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
        before = self.sf.getAdminService().lookupExperimenters()
        out, err = capsys.readouterr()
        ids = get_user_ids(out, sort_key=sort_key)
        after = self.sf.getAdminService().lookupExperimenters()

        # Check all users are listed under the assumption that
        # users won't be _deleted_ by other threads.
        if sort_key == 'login':
            sorted_before = sorted(before, key=lambda x: x.omeName.val)
            sorted_after = sorted(after, key=lambda x: x.omeName.val)
        elif sort_key == 'first-name':
            sorted_before = sorted(before, key=lambda x: x.firstName.val)
            sorted_after = sorted(after, key=lambda x: x.firstName.val)
        elif sort_key == 'last-name':
            sorted_before = sorted(before, key=lambda x: x.lastName.val)
            sorted_after = sorted(after, key=lambda x: x.lastName.val)
        elif sort_key == 'email':
            sorted_before = sorted(before,
                                   key=lambda x:
                                   (x.email and x.email.val or ""))
            sorted_after = sorted(after,
                                  key=lambda x:
                                  (x.email and x.email.val or ""))
        else:
            sorted_before = sorted(before, key=lambda x: x.id.val)
            sorted_after = sorted(after, key=lambda x: x.id.val)

        for lhs, rhs in (([user.id.val for user in sorted_before], ids),
                         (ids, [user.id.val for user in sorted_after])):
            assert len(lhs) <= len(rhs)
            assert lhs == rhs[0:len(lhs)]