aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-05-14 13:50:05 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-05-14 13:50:05 +0300
commitc2a966e3ae6c129e294ab769143f48b75cad0dd9 (patch)
tree187f8d1e5a98cd18690719122fdd8ca468ef8ec9
parente0a67d999abe3883f25e04dff3f7287ebdc3d6cf (diff)
Add fifo ordering test
-rw-r--r--test.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test.py b/test.py
index 23ae883..e1fc086 100644
--- a/test.py
+++ b/test.py
@@ -139,5 +139,28 @@ class TestFemtoQueue(unittest.TestCase):
# The task should not be returned again
self.assertIsNone(q.pop())
+ def test_fifo_order(self):
+ dir = mkdtemp()
+ q = FemtoQueue(data_dir=dir, node_name="node1")
+
+ num_tasks = 100
+
+ # Push tasks with sequential numbers as content
+ for i in range(num_tasks):
+ q.push(str(i).encode("utf-8"))
+
+ last_value = -1
+ for _ in range(num_tasks):
+ task = q.pop()
+ self.assertIsNotNone(task)
+ task = cast(FemtoTask, task)
+ current_value = int(task.data.decode("utf-8"))
+ self.assertEqual(current_value, last_value + 1)
+ last_value = current_value
+ q.done(task)
+
+ # Queue should now be empty
+ self.assertIsNone(q.pop())
+
if __name__ == '__main__':
unittest.main()