Beispiel #1
0
 def test_zlib_fresh_client(self):
     props = ClientPropertiesFactory.create( \
                             streaming=True,
                             encoding=ClientProperties.ENCODING_ZLIB)
     group = SubscriptionGroup(props)
     serialization = props.serialization
     client = _MockClient()
     group.subscribe(client)
     events1 = _MockEventsPack(['This is event 1', 'Another event'])
     events2 = _MockEventsPack(['This is event 3', 'And the last event'])
     group.dispatch(events1)
     self.assertEqual(_zlib_decompress_part(client.sent_data),
                      events1.serialize(serialization))
     group.dispatch(events2)
     self.assertEqual(_zlib_decompress_part(client.sent_data),
                      (events1.serialize(serialization) +
                       events2.serialize(serialization)))
 def test_zlib_fresh_client(self):
     props = ClientPropertiesFactory.create( \
                             streaming=True,
                             encoding=ClientProperties.ENCODING_ZLIB)
     group = SubscriptionGroup(props)
     serialization = props.serialization
     client = _MockClient()
     group.subscribe(client)
     events1 = _MockEventsPack(['This is event 1', 'Another event'])
     events2 = _MockEventsPack(['This is event 3', 'And the last event'])
     group.dispatch(events1)
     self.assertEqual(_zlib_decompress_part(client.sent_data),
                      events1.serialize(serialization))
     group.dispatch(events2)
     self.assertEqual(_zlib_decompress_part(client.sent_data),
                      (events1.serialize(serialization)
                       + events2.serialize(serialization)))
Beispiel #3
0
    def test_zlib_client_with_last_seen(self):
        props = ClientPropertiesFactory.create( \
                                streaming=True,
                                encoding=ClientProperties.ENCODING_ZLIB)
        group = SubscriptionGroup(props)
        serialization = props.serialization
        client = _MockClient()
        initial_data = 'This is a pack of initial data.'
        client.send(ztreamy.dispatchers.compress_zlib(initial_data))
        group.subscribe(client)
        events1 = _MockEventsPack(['This is event 1', 'Another event'])
        events2 = _MockEventsPack(['This is event 3', 'And the last event'])
        self.assertEqual(_zlib_decompress_part(client.sent_data), initial_data)
        group.dispatch(events1)
        self.assertEqual(_zlib_decompress_part(client.sent_data),
                         (initial_data + events1.serialize(serialization)))

        group.dispatch(events2)
        self.assertEqual(_zlib_decompress_part(client.sent_data),
                         (initial_data + events1.serialize(serialization) +
                          events2.serialize(serialization)))
    def test_zlib_client_with_last_seen(self):
        props = ClientPropertiesFactory.create( \
                                streaming=True,
                                encoding=ClientProperties.ENCODING_ZLIB)
        group = SubscriptionGroup(props)
        serialization = props.serialization
        client = _MockClient()
        initial_data = 'This is a pack of initial data.'
        client.send(ztreamy.dispatchers.compress_zlib(initial_data))
        group.subscribe(client)
        events1 = _MockEventsPack(['This is event 1', 'Another event'])
        events2 = _MockEventsPack(['This is event 3', 'And the last event'])
        self.assertEqual(_zlib_decompress_part(client.sent_data),
                         initial_data)
        group.dispatch(events1)
        self.assertEqual(_zlib_decompress_part(client.sent_data),
                         (initial_data
                          + events1.serialize(serialization)))

        group.dispatch(events2)
        self.assertEqual(_zlib_decompress_part(client.sent_data),
                         (initial_data
                          + events1.serialize(serialization)
                          + events2.serialize(serialization)))