Skip to content

Commit 12a6aef

Browse files
Lingling PengLingling Peng
authored andcommitted
add sync test
1 parent 2884171 commit 12a6aef

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

tests/integration/synapseclient/models/async/test_team_async.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,14 @@ async def test_get_user_membership_status(self) -> None:
156156
)
157157

158158
# THEN the creator should have membership status indicating they are a member
159-
assert creator_status is not None
160-
assert creator_status.team_id == str(test_team.id)
161159
assert creator_status.is_member is True
160+
assert creator_status.team_id == str(test_team.id)
161+
assert creator_status.has_open_invitation is False
162+
assert creator_status.has_open_request is False
163+
assert creator_status.can_join is True
164+
assert creator_status.membership_approval_required is False
165+
assert creator_status.has_unmet_access_requirement is False
166+
assert creator_status.can_send_email is True
162167

163168
# WHEN I invite a test user to the team
164169
invite = await test_team.invite_async(

tests/integration/synapseclient/models/synchronous/test_team.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,46 @@ async def test_team_membership_and_invitations(self) -> None:
143143

144144
# Clean up
145145
test_team.delete()
146+
147+
async def test_team_membership_status(self) -> None:
148+
"""Test getting user membership status in a team"""
149+
# GIVEN a team object
150+
151+
# WHEN I create the team on Synapse
152+
test_team = self.team.create()
153+
154+
# AND I get the membership status for the creator (who should be a member)
155+
creator_status = test_team.get_user_membership_status(
156+
user_id=self.syn.getUserProfile().ownerId
157+
)
158+
159+
# THEN the creator should have membership status indicating they are a member
160+
assert creator_status.is_member is True
161+
assert creator_status.team_id == str(test_team.id)
162+
assert creator_status.has_open_invitation is False
163+
assert creator_status.has_open_request is False
164+
assert creator_status.can_join is True
165+
assert creator_status.membership_approval_required is False
166+
assert creator_status.has_unmet_access_requirement is False
167+
assert creator_status.can_send_email is True
168+
169+
# WHEN I invite a test user to the team
170+
invite = await test_team.invite_async(
171+
user=self.TEST_USER,
172+
message=self.TEST_MESSAGE,
173+
)
174+
# Check the invited user's status
175+
invited_status = await test_team.get_user_membership_status_async(
176+
user_id=self.syn.getUserProfile(self.TEST_USER).ownerId
177+
)
178+
179+
# THEN the invited user should show they have an open invitation
180+
assert invited_status is not None
181+
assert invited_status.team_id == str(test_team.id)
182+
assert invited_status.has_open_invitation is True
183+
assert invited_status.membership_approval_required is True
184+
assert invited_status.can_send_email is True
185+
assert invited_status.is_member is False
186+
187+
# Clean up
188+
test_team.delete()

0 commit comments

Comments
 (0)