From efe3a1dd0db47cc64770597ce66150a1660f74cf Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 23 Sep 2024 00:42:55 +0100 Subject: [PATCH] unit test format_batch_start --- tests/unit/graph/test_nodes.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/unit/graph/test_nodes.py b/tests/unit/graph/test_nodes.py index a0e0a8d7e56..ad60f54d917 100644 --- a/tests/unit/graph/test_nodes.py +++ b/tests/unit/graph/test_nodes.py @@ -13,6 +13,7 @@ Measure, TestMetadata, ) +from dbt.artifacts.resources.types import BatchSize from dbt.artifacts.resources.v1.semantic_model import NodeRelation from dbt.contracts.graph.model_config import TestConfig from dbt.contracts.graph.nodes import ColumnInfo, ModelNode, ParsedNode, SemanticModel @@ -110,6 +111,22 @@ def test_all_constraints( assert default_model_node.all_constraints == expected_all_constraints + @pytest.mark.parametrize( + "batch_size,batch_start,expected_formatted_batch_start", + [ + (None, None, None), + (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"), + ], + ) + def test_format_batch_start( + self, default_model_node, batch_size, batch_start, expected_formatted_batch_start + ): + default_model_node.config.batch_size = batch_size + assert default_model_node.format_batch_start(batch_start) == expected_formatted_batch_start + class TestSemanticModel: @pytest.fixture(scope="function")