Skip to content

Commit

Permalink
add regression test for wildcard filters
Browse files Browse the repository at this point in the history
  • Loading branch information
thebalaa committed Jan 4, 2024
1 parent 1c8f5fd commit 1d95bc1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
25 changes: 24 additions & 1 deletion tests/rest/client/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,30 @@ def test_room_messages_purge(self) -> None:
self.assertEqual(len(chunk), 0, [event["content"] for event in chunk])

def test_room_message_filter_wildcard(self) -> None:
assert False
store = self.hs.get_datastores().main
# Send a first message in the room, which will be removed by the purge.
self.helper.send(self.room_id, "message 1", type="f.message.1")
self.helper.send(self.room_id, "message 1", type="f.message.2")

first_event_id = self.helper.send(self.room_id, "message 1")["event_id"]
first_token = self.get_success(
store.get_topological_token_for_event(first_event_id)
)
first_token_str = self.get_success(first_token.to_string(store))

channel = self.make_request(
"GET",
"/rooms/%s/messages?access_token=x&from=%s&dir=b&filter=%s"
% (
self.room_id,
first_token_str,
json.dumps({"types": ['f.message.*']}),
),
)
self.assertEqual(channel.code, HTTPStatus.OK, channel.json_body)

chunk = channel.json_body["chunk"]
self.assertEqual(len(chunk), 2, [event["content"] for event in chunk])


class RoomSearchTestCase(unittest.HomeserverTestCase):
Expand Down
3 changes: 2 additions & 1 deletion tests/rest/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ def send(
tok: Optional[str] = None,
expect_code: int = HTTPStatus.OK,
custom_headers: Optional[Iterable[Tuple[AnyStr, AnyStr]]] = None,
type: str = "m.room.message",
) -> JsonDict:
if body is None:
body = "body_text_here"
Expand All @@ -372,7 +373,7 @@ def send(

return self.send_event(
room_id,
"m.room.message",
type,
content,
txn_id,
tok,
Expand Down

0 comments on commit 1d95bc1

Please sign in to comment.