Пример #1
0
    def test_LongTag(self):

        t = proto_helpers.StringIOWithoutClosing()
        a = LongTagLengthTester()
        a.makeConnection(protocol.FileWrapper(t))
        for i in range(len(self.fix_buffers)):
            a.dataReceived(self.fix_buffers[i])
            self.assertEqual(self.output[i], a.longTags)
Пример #2
0
    def test_tagRecieved(self):

        t = proto_helpers.StringIOWithoutClosing()
        a = FixTagReceiverTester()
        a.makeConnection(protocol.FileWrapper(t))
        for i in range(0, len(self.fix_buffers)):
            a.dataReceived(self.fix_buffers[i])

            self.assertEqual(self.output[i], a.tags)
Пример #3
0
 def test_lineReceiverAsProducer(self):
     """
     Test produce/unproduce in receiving.
     """
     a = LineTester()
     t = proto_helpers.StringIOWithoutClosing()
     a.makeConnection(protocol.FileWrapper(t))
     a.dataReceived('produce\nhello world\nunproduce\ngoodbye\n')
     self.assertEquals(a.received,
                       ['produce', 'hello world', 'unproduce', 'goodbye'])
Пример #4
0
 def test_stackRecursion(self):
     """
     Test switching modes many times on the same data.
     """
     proto = FlippingLineTester()
     transport = proto_helpers.StringIOWithoutClosing()
     proto.makeConnection(protocol.FileWrapper(transport))
     limit = sys.getrecursionlimit()
     proto.dataReceived(b'x\nx' * limit)
     self.assertEqual(b'x' * limit, b''.join(proto.lines))
Пример #5
0
 def test_lineReceiverAsProducer(self):
     """
     Test produce/unproduce in receiving.
     """
     a = LineTester()
     t = proto_helpers.StringIOWithoutClosing()
     a.makeConnection(protocol.FileWrapper(t))
     a.dataReceived(b"produce\nhello world\nunproduce\ngoodbye\n")
     self.assertEqual(
         a.received, [b"produce", b"hello world", b"unproduce", b"goodbye"])
Пример #6
0
 def test_stopProducing(self):
     """
     Test stop inside producing.
     """
     for packet_size in range(1, 10):
         t = proto_helpers.StringIOWithoutClosing()
         a = LineTester()
         a.makeConnection(protocol.FileWrapper(t))
         for i in range(len(self.stop_buf)/packet_size + 1):
             s = self.stop_buf[i*packet_size:(i+1)*packet_size]
             a.dataReceived(s)
         self.assertEquals(self.stop_output, a.received)
Пример #7
0
 def testBuffer(self):
     """
     Test buffering for different packet size, checking received matches
     expected data.
     """
     for packet_size in range(1, 10):
         t = proto_helpers.StringIOWithoutClosing()
         a = LineTester()
         a.makeConnection(protocol.FileWrapper(t))
         for i in range(len(self.buffer)/packet_size + 1):
             s = self.buffer[i*packet_size:(i+1)*packet_size]
             a.dataReceived(s)
         self.failUnlessEqual(self.output, a.received)
Пример #8
0
 def test_rawPausing(self):
     """
     Test pause inside raw date receiving.
     """
     for packet_size in range(1, 10):
         t = proto_helpers.StringIOWithoutClosing()
         clock = task.Clock()
         a = LineTester(clock)
         a.makeConnection(protocol.FileWrapper(t))
         for i in range(len(self.rawpause_buf)/packet_size + 1):
             s = self.rawpause_buf[i*packet_size:(i+1)*packet_size]
             a.dataReceived(s)
         self.assertEquals(self.rawpause_output1, a.received)
         clock.advance(0)
         self.assertEquals(self.rawpause_output2, a.received)
Пример #9
0
 def test_pausing(self):
     """
     Test pause inside data receiving. It uses fake clock to see if
     pausing/resuming work.
     """
     for packet_size in range(1, 10):
         t = proto_helpers.StringIOWithoutClosing()
         clock = task.Clock()
         a = LineTester(clock)
         a.makeConnection(protocol.FileWrapper(t))
         for i in range(len(self.pauseBuf) // packet_size + 1):
             s = self.pauseBuf[i * packet_size:(i + 1) * packet_size]
             a.dataReceived(s)
         self.assertEqual(self.pauseOutput1, a.received)
         clock.advance(0)
         self.assertEqual(self.pauseOutput2, a.received)
Пример #10
0
 def test_simple_packet(self):
     """
     Test buffering for different packet size, checking received matches
     expected data.
     """
     for tf in test_factory.test_factories.itervalues():
         test_pdu = tf()
         pdu_data = test_pdu.pack()
         for packet_size in range(1, len(pdu_data)):
             transport = proto_helpers.StringIOWithoutClosing()
             uls = DICOMUpperLayerServiceTester()
             uls.makeConnection(protocol.FileWrapper(transport))
             for i in range(len(pdu_data) // packet_size + 1):
                 s = pdu_data[i * packet_size:(i + 1) * packet_size]
                 uls.dataReceived(s)
             self.assertEqual(len(uls.received), 1)
             self.assertEqual(uls.received[0].pack(), test_pdu.pack())