Skip to content

Commit 2b53100

Browse files
feat: added test for pinning / unpinning
1 parent 7e4a6c8 commit 2b53100

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

stream_chat/tests/test_channel.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,30 @@ def test_export_channel(
377377
assert "error" not in resp
378378
break
379379
time.sleep(0.5)
380+
381+
def test_pin_channel(self, client: StreamChat, channel: Channel, random_users: List[Dict]):
382+
user_id = random_users[0]["id"]
383+
384+
# Pin the channel
385+
response = channel.pin(user_id)
386+
assert response is not None
387+
388+
# Query for pinned channels
389+
response = client.query_channels(
390+
{"pinned": True, "cid": channel.cid},
391+
user_id=user_id
392+
)
393+
assert len(response["channels"]) == 1
394+
assert response["channels"][0]["cid"] == channel.cid
395+
396+
# Unpin the channel
397+
response = channel.unpin(user_id)
398+
assert response is not None
399+
400+
# Query for pinned channels
401+
response = client.query_channels(
402+
{"pinned": False, "cid": channel.cid},
403+
user_id=user_id
404+
)
405+
assert len(response["channels"]) == 1
406+
assert response["channels"][0]["cid"] == channel.cid

0 commit comments

Comments
 (0)