Пример #1
0
 def test_queue_persistence(self):
     queue = channel.QueueBase(None, self.persistence_directory)
     queue.put(1)
     queue.put(2)
     self.assertEqual(1, queue.get())
     queue.put(3)
     del queue
     queue = channel.QueueBase(None, self.persistence_directory)
     queue.put(4)
     self.assertEqual(2, queue.get())
     self.assertEqual(3, queue.get())
     self.assertEqual(4, queue.get())
     self.assertEqual(None, queue.get())
 def test_max_queue_length_works_as_expected(self):
     actual = channel.QueueBase(None)
     self.assertEqual(500, actual.max_queue_length)
     actual.max_queue_length = 1000
     self.assertEqual(1000, actual.max_queue_length)
     actual.max_queue_length = -1
     self.assertEqual(1, actual.max_queue_length)
 def test_construct(self):
     sender = MockQueueBaseSender()
     actual = channel.QueueBase(sender)
     self.assertIsNotNone(actual)
     self.assertEqual(500, actual.max_queue_length)
     self.assertEqual(sender, actual.sender)
     self.assertEqual(actual, sender.queue)
Пример #4
0
 def test_send_works_as_expected(self):
     port = random.randint(50000, 60000)
     actual = channel.SenderBase("http://localhost:" + str(port) + "/track")
     actual.queue = channel.QueueBase(None)
     MockHTTPRequestHandler.ExpectedContent = "[42, 13]"
     MockHTTPRequestHandler.TestCase = self  # save a reference to the test case in our handler
     thread = WorkerThread(actual)
     thread.start()
     runHttpHandlerOnce(handler=MockHTTPRequestHandler,
                        port=port)  # run the HTTP request
     thread.join()
     if "failed" in dir(self):
         self.fail(self.failed)
     self.assertEqual(None, actual.queue.get())
 def test_sender_works_as_expected(self):
     sender = MockQueueBaseSender()
     actual = channel.QueueBase(sender)
     self.assertEqual(sender, actual.sender)
Пример #6
0
 def test_queue_persistence_without_dependency(self):
     with self.assertRaises(ValueError):
         channel.QueueBase(None, self.persistence_directory)