Skip to content

Commit

Permalink
test_user: don't assume single-threaded (see ome#6206)
Browse files Browse the repository at this point in the history
`omero user list` was compared to the output of iadmin.lookupExperimenters().
Depending on the interval, other users could have been added. Now we assume
monotonically increasing users.
  • Loading branch information
joshmoore committed Jan 27, 2020
1 parent 11f81d5 commit 7edd892
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions components/tools/OmeroPy/test/integration/clitest/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,35 @@ def testList(self, capsys, sort_key, 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
# Check all users are listed under the assumption that
# users won't be _deleted_ by other threads.
if sort_key == 'login':
sorted_list = sorted(self.users, key=lambda x: x.omeName.val)
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_list = sorted(self.users, key=lambda x: x.firstName.val)
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_list = sorted(self.users, key=lambda x: x.lastName.val)
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_list = sorted(self.users, key=lambda x: (
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_list = sorted(self.users, key=lambda x: x.id.val)
assert ids == [user.id.val for user in sorted_list]
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)]

@pytest.mark.parametrize("style", [None, "sql", "csv", "plain", "json"])
def testListWithStyles(self, capsys, style):
Expand Down

0 comments on commit 7edd892

Please sign in to comment.