From fe73096cddab20d67d0a61f57eb70ad21ab3af08 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 16 Jan 2025 18:19:37 -0700 Subject: [PATCH] Add tests for batch_id and change expected output for format_batch_start --- .../incremental/test_microbatch.py | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/unit/materializations/incremental/test_microbatch.py b/tests/unit/materializations/incremental/test_microbatch.py index 3d827a79975..06519d4994c 100644 --- a/tests/unit/materializations/incremental/test_microbatch.py +++ b/tests/unit/materializations/incremental/test_microbatch.py @@ -602,13 +602,25 @@ def test_offset_timestamp(self, timestamp, batch_size, offset, expected_timestam def test_truncate_timestamp(self, timestamp, batch_size, expected_timestamp): assert MicrobatchBuilder.truncate_timestamp(timestamp, batch_size) == expected_timestamp + @pytest.mark.parametrize( + "batch_size,start_time,expected_formatted_start_time", + [ + (BatchSize.year, datetime(2020, 1, 1, 1), "20200101"), + (BatchSize.month, datetime(2020, 1, 1, 1), "20200101"), + (BatchSize.day, datetime(2020, 1, 1, 1), "20200101"), + (BatchSize.hour, datetime(2020, 1, 1, 1), "20200101T01"), + ], + ) + def test_batch_id(self, batch_size, start_time, expected_formatted_start_time): + assert MicrobatchBuilder.batch_id(start_time, batch_size) == expected_formatted_start_time + @pytest.mark.parametrize( "batch_size,batch_start,expected_formatted_batch_start", [ - (BatchSize.year, datetime(2020, 1, 1, 1), "2020-01-01"), - (BatchSize.month, datetime(2020, 1, 1, 1), "2020-01-01"), - (BatchSize.day, datetime(2020, 1, 1, 1), "2020-01-01"), - (BatchSize.hour, datetime(2020, 1, 1, 1), "2020-01-01 01:00:00"), + (BatchSize.year, datetime(2020, 1, 1, 1), "20200101"), + (BatchSize.month, datetime(2020, 1, 1, 1), "20200101"), + (BatchSize.day, datetime(2020, 1, 1, 1), "20200101"), + (BatchSize.hour, datetime(2020, 1, 1, 1), "20200101T01"), ], ) def test_format_batch_start(self, batch_size, batch_start, expected_formatted_batch_start):