Skip to content

Commit b80c3d9

Browse files
[CHA-0] Fix QueryReminders to use filter parameter and improve test assertions (#214)
* feat: Fix QueryReminders to use filter parameter instead of filter_conditions * feat: Improve QueryReminders tests to verify filter results actually match criteria
1 parent b9b7837 commit b80c3d9

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

stream_chat/async_chat/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ async def query_reminders(
965965
:return: API response with reminders
966966
"""
967967
params = options.copy()
968-
params["filter_conditions"] = filter_conditions or {}
968+
params["filter"] = filter_conditions or {}
969969
params["sort"] = sort or [{"field": "remind_at", "direction": 1}]
970970
params["user_id"] = user_id
971971
return await self.post("reminders/query", data=params)

stream_chat/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ def query_reminders(
919919
:return: API response with reminders
920920
"""
921921
params = options.copy()
922-
params["filter_conditions"] = filter_conditions or {}
922+
params["filter"] = filter_conditions or {}
923923
params["sort"] = sort or [{"field": "remind_at", "direction": 1}]
924924
params["user_id"] = user_id
925925
return self.post("reminders/query", data=params)

stream_chat/tests/async_chat/test_reminders.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,30 @@ async def test_query_reminders(self, client: StreamChatAsync, channel, random_us
158158
random_user["id"], filter_conditions
159159
)
160160
assert response is not None
161+
assert "reminders" in response
162+
# Verify all returned reminders match the filter
163+
for reminder in response["reminders"]:
164+
assert reminder["message_id"] in [message_ids[0]]
161165

162-
# Test case 3: Query reminders by channel CID
166+
# Test case 3: Query reminders by single message ID
167+
filter_conditions = {"message_id": message_ids[0]}
168+
response = await client.query_reminders(random_user["id"], filter_conditions)
169+
assert response is not None
170+
assert "reminders" in response
171+
assert len(response["reminders"]) >= 1
172+
# Verify all returned reminders have the exact message_id
173+
for reminder in response["reminders"]:
174+
assert reminder["message_id"] == message_ids[0]
175+
176+
# Test case 4: Query reminders by channel CID
163177
filter_conditions = {"channel_cid": channel_cid}
164178
response = await client.query_reminders(random_user["id"], filter_conditions)
165179
assert response is not None
180+
assert "reminders" in response
181+
assert len(response["reminders"]) >= 3
182+
# Verify all returned reminders belong to the channel
183+
for reminder in response["reminders"]:
184+
assert reminder["channel_cid"] == channel_cid
166185

167186
# Clean up - try to delete the reminders
168187
for message_id in message_ids:

stream_chat/tests/test_reminders.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,30 @@ def test_query_reminders(self, client: StreamChat, channel, random_user):
146146
filter_conditions = {"message_id": {"$in": [message_ids[0]]}}
147147
response = client.query_reminders(random_user["id"], filter_conditions)
148148
assert response is not None
149+
assert "reminders" in response
150+
# Verify all returned reminders match the filter
151+
for reminder in response["reminders"]:
152+
assert reminder["message_id"] in [message_ids[0]]
149153

150-
# Test case 3: Query reminders by channel CID
154+
# Test case 3: Query reminders by single message ID
155+
filter_conditions = {"message_id": message_ids[0]}
156+
response = client.query_reminders(random_user["id"], filter_conditions)
157+
assert response is not None
158+
assert "reminders" in response
159+
assert len(response["reminders"]) >= 1
160+
# Verify all returned reminders have the exact message_id
161+
for reminder in response["reminders"]:
162+
assert reminder["message_id"] == message_ids[0]
163+
164+
# Test case 4: Query reminders by channel CID
151165
filter_conditions = {"channel_cid": channel_cid}
152166
response = client.query_reminders(random_user["id"], filter_conditions)
153167
assert response is not None
168+
assert "reminders" in response
169+
assert len(response["reminders"]) >= 3
170+
# Verify all returned reminders belong to the channel
171+
for reminder in response["reminders"]:
172+
assert reminder["channel_cid"] == channel_cid
154173

155174
# Clean up - try to delete the reminders
156175
for message_id in message_ids:

0 commit comments

Comments
 (0)