aboutsummaryrefslogtreecommitdiff
path: root/gn2/tests/unit/utility/test_chunks.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn2/tests/unit/utility/test_chunks.py')
-rw-r--r--gn2/tests/unit/utility/test_chunks.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/gn2/tests/unit/utility/test_chunks.py b/gn2/tests/unit/utility/test_chunks.py
new file mode 100644
index 00000000..1b5a9413
--- /dev/null
+++ b/gn2/tests/unit/utility/test_chunks.py
@@ -0,0 +1,20 @@
+"""Test chunking"""
+
+import unittest
+
+from gn2.utility.chunks import divide_into_chunks
+
+
+class TestChunks(unittest.TestCase):
+ "Test Utility method for chunking"
+
+ def test_divide_into_chunks(self):
+ "Check that a list is chunked correctly"
+ self.assertEqual(divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 3),
+ [[1, 2, 7], [3, 22, 8], [5, 22, 333]])
+ self.assertEqual(divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 4),
+ [[1, 2, 7], [3, 22, 8], [5, 22, 333]])
+ self.assertEqual(divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 5),
+ [[1, 2], [7, 3], [22, 8], [5, 22], [333]])
+ self.assertEqual(divide_into_chunks([], 5),
+ [[]])