示例#1
0
 def test_rpc_on_multiple_frames(self):
     rpc = Rpc(FakeConnection())
     uuid = rpc.register_request(['Test'])
     self.assertEqual(rpc._response[uuid], [])
     rpc.on_frame(FakePayload(name='Test'))
     rpc.on_frame(FakePayload(name='Test'))
     rpc.on_frame(FakePayload(name='Test'))
     self.assertIsInstance(rpc._response[uuid][0], FakePayload)
     self.assertIsInstance(rpc._response[uuid][1], FakePayload)
     self.assertIsInstance(rpc._response[uuid][2], FakePayload)
示例#2
0
    def test_rpc_get_request_multiple_2(self):
        rpc = Rpc(FakeConnection())
        uuid = rpc.register_request(['Test'])
        for index in range(1000):
            rpc.on_frame(FakePayload(name='Test', value=index))
            result = rpc.get_request(uuid=uuid, raw=True, multiple=True)
            self.assertEqual(result.value, index)

        rpc.remove(uuid)
示例#3
0
 def test_rpc_remove_multiple(self):
     rpc = Rpc(FakeConnection())
     uuid = rpc.register_request(['Test'])
     for index in range(1000):
         rpc.on_frame(FakePayload(name='Test', value=index))
     self.assertEqual(len(rpc._request), 1)
     self.assertEqual(len(rpc._response[uuid]), 1000)
     rpc.remove(uuid)
     self.assertEqual(len(rpc._request), 0)
     self.assertEqual(len(rpc._response), 0)
示例#4
0
 def test_rpc_remove(self):
     rpc = Rpc(FakeConnection())
     uuid = rpc.register_request(['Test'])
     self.assertEqual(len(rpc._request), 1)
     self.assertEqual(len(rpc._response), 1)
     self.assertEqual(len(rpc._response[uuid]), 0)
     rpc.on_frame(FakePayload(name='Test'))
     rpc.remove(uuid)
     self.assertEqual(len(rpc._request), 0)
     self.assertEqual(len(rpc._response), 0)
示例#5
0
 def test_rpc_get_request(self):
     rpc = Rpc(FakeConnection())
     uuid = rpc.register_request(['Test'])
     self.assertTrue(rpc.on_frame(FakePayload(name='Test')))
     self.assertIsInstance(rpc.get_request(uuid=uuid, raw=True),
                           FakePayload)
示例#6
0
 def delivery_payload():
     time.sleep(0.1)
     rpc.on_frame(FakePayload(name='travis-ci'))
示例#7
0
 def test_rpc_on_frame(self):
     rpc = Rpc(FakeConnection())
     uuid = rpc.register_request(['travis-ci'])
     self.assertEqual(rpc._response[uuid], [])
     rpc.on_frame(FakePayload(name='travis-ci'))
     self.assertIsInstance(rpc._response[uuid][0], FakePayload)