Skip to content

Commit

Permalink
Merge pull request #3200 from cisagov/za/bugfix-failing-member-test
Browse files Browse the repository at this point in the history
BUGFIX: Add order_by on MemberExport to fix flaky test
  • Loading branch information
zandercymatics authored Dec 10, 2024
2 parents abf8a46 + 5d22876 commit f1f7a06
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
28 changes: 18 additions & 10 deletions src/registrar/tests/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,18 +874,26 @@ def test_member_export(self):
"Email,Organization admin,Invited by,Joined date,Last active,Domain requests,"
"Member management,Domain management,Number of domains,Domains\n"
# Content
"[email protected],False,[email protected],2022-04-01,Invalid date,None,"
"Viewer,True,1,cdomain1.gov\n"
"[email protected],True,[email protected],2022-04-01,2024-02-01,"
"Viewer,Viewer,False,0,\n"
"[email protected],True,[email protected],2022-04-01,2024-02-01,"
"Viewer Requester,Manager,False,0,\n"
"[email protected],False,[email protected],2022-04-01,Invalid date,None,"
'Manager,True,2,"adomain2.gov,cdomain1.gov"\n'
"[email protected],False,[email protected],2022-04-01,Invalid date,None,Viewer,True,1,cdomain1.gov\n"
"[email protected],False,System,2022-04-01,Invalid date,Viewer,None,False,0,\n"
"[email protected],True,[email protected],2022-04-01,2024-02-01,Viewer Requester,Manager,False,0,\n"
"[email protected],True,[email protected],2022-04-01,2024-02-01,Viewer,Viewer,False,0,\n"
"[email protected],False,[email protected],Unretrieved,Invited,None,Manager,False,0,\n"
"[email protected],False,[email protected],Unretrieved,Invited,None,Viewer,False,0,\n"
"[email protected],False,[email protected],Unretrieved,Invited,Viewer,None,False,0,\n"
"[email protected],True,[email protected],Unretrieved,"
"Invited,Viewer Requester,Manager,False,0,\n"
"[email protected],True,[email protected],Unretrieved,Invited,Viewer,Viewer,False,0,\n"
"[email protected],False,[email protected],Unretrieved,Invited,"
"None,Manager,False,0,\n"
"[email protected],False,[email protected],Unretrieved,Invited,"
"None,Viewer,False,0,\n"
"[email protected],False,[email protected],Unretrieved,Invited,"
"Viewer,None,False,0,\n"
"[email protected],True,[email protected],Unretrieved,Invited,"
"Viewer Requester,Manager,False,0,\n"
"[email protected],True,[email protected],Unretrieved,Invited,"
"Viewer,Viewer,False,0,\n"
"[email protected],False,System,2022-04-01,Invalid date,Viewer,"
"None,False,0,\n"
)
# Normalize line endings and remove commas,
# spaces and leading/trailing whitespace
Expand Down
7 changes: 5 additions & 2 deletions src/registrar/utility/csv_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,11 @@ def get_model_annotation_dict(cls, request=None, **kwargs):
)
.values(*shared_columns)
)

return convert_queryset_to_dict(permissions.union(invitations), is_model=False)
# Adding a order_by increases output predictability.
# Doesn't matter as much for normal use, but makes tests easier.
# We should also just be ordering by default anyway.
members = permissions.union(invitations).order_by("email_display")
return convert_queryset_to_dict(members, is_model=False)

@classmethod
def get_invited_by_query(cls, object_id_query):
Expand Down

0 comments on commit f1f7a06

Please sign in to comment.