Serialize pending invites to return "id" not "_id" (#559)

This commit is contained in:
Tessa Walsh 2023-02-06 12:28:11 -05:00 committed by GitHub
parent 28d39121d7
commit 6d424a1ae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -192,10 +192,11 @@ class InviteOps:
async def get_pending_invites(self, org=None):
"""return list of pending invites."""
if org:
invites = self.invites.find({"oid": org.id})
cursor = self.invites.find({"oid": org.id})
else:
invites = self.invites.find()
return [invite async for invite in invites]
cursor = self.invites.find()
results = await cursor.to_list(length=1000)
return [InvitePending.from_dict(result) for result in results]
def init_invites(mdb, email):

View File

@ -27,7 +27,7 @@ def test_pending_invites(admin_auth_headers, default_org_id):
invites = data["pending_invites"]
assert len(invites) == 1
invite = invites[0]
assert invite["_id"]
assert invite["id"]
assert invite["email"] == INVITE_EMAIL
assert invite["oid"] == default_org_id
assert invite["created"]

View File

@ -147,7 +147,7 @@ def test_get_pending_org_invites(
invites = data["pending_invites"]
assert len(invites) == 1
invite = invites[0]
assert invite["_id"]
assert invite["id"]
assert invite["email"] == INVITE_EMAIL
assert invite["oid"] == non_default_org_id
assert invite["created"]