@@ -115,7 +115,7 @@ def test_add_message_includes_mentions():
115115 msg = chat .get_message (msg_id )
116116 assert msg
117117
118- assert set (msg .mentions ) == set ([USER2 .username , USER3 .username ])
118+ assert sorted (msg .mentions ) == sorted ([USER2 .username , USER3 .username ])
119119
120120
121121def test_get_message_should_return_the_message ():
@@ -173,19 +173,17 @@ def test_update_message_includes_mentions():
173173 chat .set_user (USER2 )
174174 chat .set_user (USER3 )
175175
176- # Add a message with one mention
177176 new_msg = create_new_message (f"@{ USER2 .mention_name } Hello!" )
178177 msg_id = chat .add_message (new_msg )
179178 msg = chat .get_message (msg_id )
180179 assert msg
181- assert set ( msg .mentions ) == set ( [USER2 .username ])
180+ assert msg .mentions == [USER2 .username ]
182181
183- # Update the message to mention a different user
184182 msg .body = f"@{ USER3 .mention_name } Goodbye!"
185183 chat .update_message (msg , find_mentions = True )
186184 updated_msg = chat .get_message (msg_id )
187185 assert updated_msg
188- assert set ( updated_msg .mentions ) == set ( [USER3 .username ])
186+ assert updated_msg .mentions == [USER3 .username ]
189187
190188
191189def test_update_message_append_includes_mentions ():
@@ -194,41 +192,36 @@ def test_update_message_append_includes_mentions():
194192 chat .set_user (USER2 )
195193 chat .set_user (USER3 )
196194
197- # Add a message with one mention
198195 new_msg = create_new_message (f"@{ USER2 .mention_name } Hello!" )
199196 msg_id = chat .add_message (new_msg )
200197 msg = chat .get_message (msg_id )
201198 assert msg
202- assert set ( msg .mentions ) == set ( [USER2 .username ])
199+ assert msg .mentions == [USER2 .username ]
203200
204- # Append content with another mention
205201 msg .body = f" and @{ USER3 .mention_name } !"
206202 chat .update_message (msg , append = True , find_mentions = True )
207203 updated_msg = chat .get_message (msg_id )
208204 assert updated_msg
209- # Should now mention both users
210- assert set (updated_msg .mentions ) == set ([USER2 .username , USER3 .username ])
205+ assert sorted (updated_msg .mentions ) == sorted ([USER2 .username , USER3 .username ])
211206
212207
213208def test_update_message_append_no_duplicate_mentions ():
214209 chat = YChat ()
215210 chat .set_user (USER )
216211 chat .set_user (USER2 )
217212
218- # Add a message with a mention
219213 new_msg = create_new_message (f"@{ USER2 .mention_name } Hello!" )
220214 msg_id = chat .add_message (new_msg )
221215 msg = chat .get_message (msg_id )
222216 assert msg
223- assert set ( msg .mentions ) == set ( [USER2 .username ])
217+ assert msg .mentions == [USER2 .username ]
224218
225- # Append content that mentions the same user again
226219 msg .body = f" @{ USER2 .mention_name } again!"
227220 chat .update_message (msg , append = True , find_mentions = True )
228221 updated_msg = chat .get_message (msg_id )
229222 assert updated_msg
230- # Should only have one mention despite appearing twice
231- assert set (updated_msg .mentions ) == set ([ USER2 . username ])
223+ assert updated_msg . mentions == [ USER2 . username ]
224+ assert len (updated_msg .mentions ) == 1
232225
233226
234227def test_indexes_by_id ():
0 commit comments