Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay committed Jan 7, 2025
1 parent 754c27b commit 830e5e6
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/rest/client/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4070,3 +4070,50 @@ def test_suspended_user_cannot_redact_messages_other_than_their_own(self) -> Non
shorthand=False,
)
self.assertEqual(channel.code, 200)


class RoomParticipantTestCase(unittest.HomeserverTestCase):
servlets = [
login.register_servlets,
room.register_servlets,
profile.register_servlets,
admin.register_servlets,
]

def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
self.user1 = self.register_user("thomas", "hackme")
self.tok1 = self.login("thomas", "hackme")

self.user2 = self.register_user("teresa", "hackme")
self.tok2 = self.login("teresa", "hackme")

self.room1 = self.helper.create_room_as(room_creator=self.user1, tok=self.tok1)
self.store = hs.get_datastores().main

def test_sending_message_records_participation(self) -> None:
"""
Test that sending an m.room.message event into a room causes the user to
be marked as a participant in that room
"""
self.helper.join(self.room1, self.user2, tok=self.tok2)

# user has not sent any messages, so should not be a participant
participant = self.get_success(
self.store.get_room_participation(self.room1, self.user2)
)
self.assertFalse(participant)

# sending a message should now mark user as participant
self.helper.send_event(
self.room1,
"m.room.message",
content={
"msgtype": "m.text",
"body": "I am engaging in this room",
},
tok=self.tok2,
)
participant = self.get_success(
self.store.get_room_participation(self.room1, self.user2)
)
self.assertTrue(participant)

0 comments on commit 830e5e6

Please sign in to comment.