mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
events: Fix incorrectly empty event queues with virtual events.
I'm not sure this had much impact, but it's definitely a subtle bug. (imported from commit 0260d4c5c35ce8eac683e84f1d939a6704ce4e2b)
This commit is contained in:
@@ -198,7 +198,7 @@ class EventQueue(object):
|
|||||||
return self.queue.popleft()
|
return self.queue.popleft()
|
||||||
|
|
||||||
def empty(self):
|
def empty(self):
|
||||||
return len(self.queue) == 0
|
return len(self.queue) == 0 and len(self.virtual_events) == 0
|
||||||
|
|
||||||
def prune(self, through_id):
|
def prune(self, through_id):
|
||||||
while not self.empty() and self.queue[0]['id'] <= through_id:
|
while not self.empty() and self.queue[0]['id'] <= through_id:
|
||||||
|
|||||||
@@ -2483,6 +2483,7 @@ class EventQueueTest(TestCase):
|
|||||||
queue.push({"type": "pointer",
|
queue.push({"type": "pointer",
|
||||||
"pointer": 1,
|
"pointer": 1,
|
||||||
"timestamp": "1"})
|
"timestamp": "1"})
|
||||||
|
self.assertFalse(queue.empty())
|
||||||
self.assertEqual(queue.contents(),
|
self.assertEqual(queue.contents(),
|
||||||
[{'id': 0,
|
[{'id': 0,
|
||||||
'type': 'pointer',
|
'type': 'pointer',
|
||||||
|
|||||||
Reference in New Issue
Block a user