Beispiel #1
0
    def test_broken_tail(self):
        protocol = TestProtocol()
        protocol.connection_made()

        data = create_packet(3, 5, bytearray([0x00, 1, 1, 0x01, 3, 7, 8]))
        self.assertRaises(IndexError, protocol.data_received, data)

        protocol.connection_lost()

        self.assertEqual(len(protocol.results), 1)
Beispiel #2
0
    def test_broken(self):
        protocol = TestProtocol()
        protocol.connection_made()

        data = create_packet(0, 0, bytearray([0, 10, 1, 2, 3]))
        self.assertRaises(IndexError, protocol.data_received, data)

        protocol.connection_lost()

        self.assertEqual(len(protocol.results), 0)
    def test_broken_tail(self):
        protocol = TestProtocol()
        protocol.connection_made()

        data = create_packet(3, 5, bytearray([0x00, 1, 1, 0x01, 3, 7, 8]))
        self.assertRaises(IndexError, protocol.data_received, data)

        protocol.connection_lost()

        self.assertEqual(len(protocol.results), 1)
    def test_broken(self):
        protocol = TestProtocol()
        protocol.connection_made()

        data = create_packet(0, 0, bytearray([0, 10, 1, 2, 3]))
        self.assertRaises(IndexError, protocol.data_received, data)

        protocol.connection_lost()

        self.assertEqual(len(protocol.results), 0)
Beispiel #5
0
def process_dataset(dataset, start=0, end=None, fragmented=False):
    protocol = TestProtocol()
    protocol.connection_made()

    data = bytearray([]).join(create_packet(*entry) for entry in dataset)[start:end]

    if fragmented:
        for x in data:
            protocol.data_received(bytearray([x]))
    else:
        protocol.data_received(data)

    protocol.connection_lost()
    return protocol.results
Beispiel #6
0
def process_dataset(dataset, start=0, end=None, fragmented=False):
    protocol = TestProtocol()
    protocol.connection_made()

    data = bytearray([]).join(create_packet(*entry)
                              for entry in dataset)[start:end]

    if fragmented:
        for x in data:
            protocol.data_received(bytearray([x]))
    else:
        protocol.data_received(data)

    protocol.connection_lost()
    return protocol.results