예제 #1
0
파일: test_events.py 프로젝트: seanly/zulip
 def test_one_event(self):
     queue = EventQueue("1")
     queue.push({"type": "pointer",
                 "pointer": 1,
                 "timestamp": "1"})
     self.assertFalse(queue.empty())
     self.assertEqual(queue.contents(),
                      [{'id': 0,
                        'type': 'pointer',
                        "pointer": 1,
                        "timestamp": "1"}])
예제 #2
0
 def test_flag_remove_collapsing(self):
     queue = EventQueue("1")
     queue.push({
         "type": "update_message_flags",
         "flag": "collapsed",
         "operation": "remove",
         "all": False,
         "messages": [1, 2, 3, 4],
         "timestamp": "1"
     })
     queue.push({
         "type": "update_message_flags",
         "flag": "collapsed",
         "all": False,
         "operation": "remove",
         "messages": [5, 6],
         "timestamp": "1"
     })
     self.assertEqual(queue.contents(), [{
         'id': 1,
         'type': 'update_message_flags',
         "all": False,
         "flag": "collapsed",
         "operation": "remove",
         "messages": [1, 2, 3, 4, 5, 6],
         "timestamp": "1"
     }])
예제 #3
0
 def test_one_event(self):
     queue = EventQueue("1")
     queue.push({"type": "pointer", "pointer": 1, "timestamp": "1"})
     self.assertFalse(queue.empty())
     self.assertEqual(queue.contents(), [{
         'id': 0,
         'type': 'pointer',
         "pointer": 1,
         "timestamp": "1"
     }])
예제 #4
0
 def test_collapse_event(self):
     queue = EventQueue("1")
     queue.push({"type": "pointer", "pointer": 1, "timestamp": "1"})
     queue.push({"type": "unknown", "timestamp": "1"})
     self.assertEqual(queue.contents(), [{
         'id': 0,
         'type': 'pointer',
         "pointer": 1,
         "timestamp": "1"
     }, {
         'id': 1,
         'type': 'unknown',
         "timestamp": "1"
     }])
예제 #5
0
파일: test_events.py 프로젝트: seanly/zulip
 def test_collapse_event(self):
     queue = EventQueue("1")
     queue.push({"type": "pointer",
                 "pointer": 1,
                 "timestamp": "1"})
     queue.push({"type": "unknown",
                 "timestamp": "1"})
     self.assertEqual(queue.contents(),
                      [{'id': 0,
                        'type': 'pointer',
                        "pointer": 1,
                        "timestamp": "1"},
                       {'id': 1,
                        'type': 'unknown',
                        "timestamp": "1"}])
예제 #6
0
파일: test_events.py 프로젝트: seanly/zulip
 def test_flag_remove_collapsing(self):
     queue = EventQueue("1")
     queue.push({"type": "update_message_flags",
                 "flag": "collapsed",
                 "operation": "remove",
                 "all": False,
                 "messages": [1, 2, 3, 4],
                 "timestamp": "1"})
     queue.push({"type": "update_message_flags",
                 "flag": "collapsed",
                 "all": False,
                 "operation": "remove",
                 "messages": [5, 6],
                 "timestamp": "1"})
     self.assertEqual(queue.contents(),
                      [{'id': 1,
                        'type': 'update_message_flags',
                        "all": False,
                        "flag": "collapsed",
                        "operation": "remove",
                        "messages": [1, 2, 3, 4, 5, 6],
                        "timestamp": "1"}])
예제 #7
0
파일: test_events.py 프로젝트: seanly/zulip
    def test_event_collapsing(self):
        queue = EventQueue("1")
        for pointer_val in range(1, 10):
            queue.push({"type": "pointer",
                        "pointer": pointer_val,
                        "timestamp": str(pointer_val)})
        self.assertEqual(queue.contents(),
                         [{'id': 8,
                           'type': 'pointer',
                           "pointer": 9,
                           "timestamp": "9"}])

        queue = EventQueue("2")
        for pointer_val in range(1, 10):
            queue.push({"type": "pointer",
                        "pointer": pointer_val,
                        "timestamp": str(pointer_val)})
        queue.push({"type": "unknown"})
        queue.push({"type": "restart", "server_generation": "1"})
        for pointer_val in range(11, 20):
            queue.push({"type": "pointer",
                        "pointer": pointer_val,
                        "timestamp": str(pointer_val)})
        queue.push({"type": "restart", "server_generation": "2"})
        self.assertEqual(queue.contents(),
                         [{"type": "unknown",
                           "id": 9,},
                          {'id': 19,
                           'type': 'pointer',
                           "pointer": 19,
                           "timestamp": "19"},
                          {"id": 20,
                           "type": "restart",
                           "server_generation": "2"}])
        for pointer_val in range(21, 23):
            queue.push({"type": "pointer",
                        "pointer": pointer_val,
                        "timestamp": str(pointer_val)})
        self.assertEqual(queue.contents(),
                         [{"type": "unknown",
                           "id": 9,},
                          {'id': 19,
                           'type': 'pointer',
                           "pointer": 19,
                           "timestamp": "19"},
                          {"id": 20,
                           "type": "restart",
                           "server_generation": "2"},
                          {'id': 22,
                           'type': 'pointer',
                           "pointer": 22,
                           "timestamp": "22"},
                          ])
예제 #8
0
    def test_event_collapsing(self):
        queue = EventQueue("1")
        for pointer_val in range(1, 10):
            queue.push({"type": "pointer",
                        "pointer": pointer_val,
                        "timestamp": str(pointer_val)})
        self.assertEqual(queue.contents(),
                         [{'id': 8,
                           'type': 'pointer',
                           "pointer": 9,
                           "timestamp": "9"}])

        queue = EventQueue("2")
        for pointer_val in range(1, 10):
            queue.push({"type": "pointer",
                        "pointer": pointer_val,
                        "timestamp": str(pointer_val)})
        queue.push({"type": "unknown"})
        queue.push({"type": "restart", "server_generation": "1"})
        for pointer_val in range(11, 20):
            queue.push({"type": "pointer",
                        "pointer": pointer_val,
                        "timestamp": str(pointer_val)})
        queue.push({"type": "restart", "server_generation": "2"})
        self.assertEqual(queue.contents(),
                         [{"type": "unknown",
                           "id": 9,},
                          {'id': 19,
                           'type': 'pointer',
                           "pointer": 19,
                           "timestamp": "19"},
                          {"id": 20,
                           "type": "restart",
                           "server_generation": "2"}])
        for pointer_val in range(21, 23):
            queue.push({"type": "pointer",
                        "pointer": pointer_val,
                        "timestamp": str(pointer_val)})
        self.assertEqual(queue.contents(),
                         [{"type": "unknown",
                           "id": 9,},
                          {'id': 19,
                           'type': 'pointer',
                           "pointer": 19,
                           "timestamp": "19"},
                          {"id": 20,
                           "type": "restart",
                           "server_generation": "2"},
                          {'id': 22,
                           'type': 'pointer',
                           "pointer": 22,
                           "timestamp": "22"},
                          ])