Fix typing tests

This commit is contained in:
Erik Johnston 2024-09-27 10:19:42 +01:00
parent 6452e22e8f
commit e85f8f77c2
1 changed files with 21 additions and 10 deletions

View File

@ -282,22 +282,33 @@ class SyncTypingTests(unittest.HomeserverTestCase):
self.assertEqual(200, channel.code) self.assertEqual(200, channel.code)
next_batch = channel.json_body["next_batch"] next_batch = channel.json_body["next_batch"]
# This should time out! But it does not, because our stream token is
# ahead, and therefore it's saying the typing (that we've actually
# already seen) is new, since it's got a token above our new, now-reset
# stream token.
channel = self.make_request("GET", sync_url % (access_token, next_batch))
self.assertEqual(200, channel.code)
next_batch = channel.json_body["next_batch"]
# Clear the typing information, so that it doesn't think everything is # Clear the typing information, so that it doesn't think everything is
# in the future. # in the future. This happens automatically when the typing stream
# resets.
typing._reset() typing._reset()
# Now it SHOULD fail as it never completes! # Nothing new, so we time out.
with self.assertRaises(TimedOutException): with self.assertRaises(TimedOutException):
self.make_request("GET", sync_url % (access_token, next_batch)) self.make_request("GET", sync_url % (access_token, next_batch))
# Sync and start typing again.
sync_channel = self.make_request(
"GET", sync_url % (access_token, next_batch), await_result=False
)
self.assertFalse(sync_channel.is_finished())
channel = self.make_request(
"PUT",
typing_url % (room, other_user_id, other_access_token),
b'{"typing": true, "timeout": 30000}',
)
self.assertEqual(200, channel.code)
# Sync should now return.
sync_channel.await_result()
self.assertEqual(200, sync_channel.code)
next_batch = sync_channel.json_body["next_batch"]
class SyncKnockTestCase(KnockingStrippedStateEventHelperMixin): class SyncKnockTestCase(KnockingStrippedStateEventHelperMixin):
servlets = [ servlets = [