diff --git a/test/test_queuefile.py b/test/test_queuefile.py index 15858190b..9e5b4a194 100644 --- a/test/test_queuefile.py +++ b/test/test_queuefile.py @@ -1,4 +1,5 @@ import unittest +import os from StringIO import StringIO @@ -74,6 +75,44 @@ class TestQueueFile(unittest.TestCase): self.assertIsNotNone(ex_found[0]) + def test_binary_data(self): + queue = FakeQueue() + + # Generate some binary data. + binary_data = os.urandom(1024) + queue.put(QueueResult(binary_data, None)) + queue.put(QueueResult(None, None)) + + queuefile = QueueFile(queue) + found_data = '' + while True: + current_data = queuefile.read(size=37) + if len(current_data) == 0: + break + + found_data = found_data + current_data + + self.assertEquals(found_data, binary_data) + + def test_empty_data(self): + queue = FakeQueue() + + # Generate some empty binary data. + binary_data = '\0' * 1024 + queue.put(QueueResult(binary_data, None)) + queue.put(QueueResult(None, None)) + + queuefile = QueueFile(queue) + found_data = '' + while True: + current_data = queuefile.read(size=37) + if len(current_data) == 0: + break + + found_data = found_data + current_data + + self.assertEquals(found_data, binary_data) + if __name__ == '__main__': unittest.main()