From 52fe65c995b2b6824e94844f875d252f6c481afb Mon Sep 17 00:00:00 2001 From: Ben Welsh Date: Mon, 2 Jan 2023 15:48:36 -0800 Subject: [PATCH] Add tests for the batch and chunk commands (#359) * Add tests for the batch and chunk commands Fixes #330 * Flake fix --- tests/test_utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_utils.py b/tests/test_utils.py index cb40189b9d2..5d9ce670467 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -128,3 +128,16 @@ def test_get_url(): utils.get_json_url( "https://archive.org/download/signalcleveland-2022/signalcleveland-2022-11-17T02%3A50%3A58.280867-05%3A00.wayback.json" ) + + +def test_chunk(): + """Test the chunk utility.""" + assert len(utils.chunk([1, 2, 3, 4, 5], 2)) == 3 + assert len(utils.chunk([1, 2, 3, 4, 5], 5)) == 1 + assert len(utils.chunk([1, 2, 3, 4, 5], 4)) == 2 + + +def test_batch(): + """Test the batch utility.""" + assert len(list(utils.batch([1, 2, 3, 4, 5], 2))) == 2 + assert len(list(utils.batch([1, 2, 3, 4, 5], 1))) == 1