Skip to content

Commit

Permalink
Add tests for batch_id and change expected output for format_batch_start
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeatty10 committed Jan 17, 2025
1 parent 85e0e32 commit fe73096
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/unit/materializations/incremental/test_microbatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit fe73096

Please sign in to comment.