From 8dc4228fb926c86441cd24d2abd3a6ddb3f24bdc Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Thu, 9 May 2024 17:08:21 -0700 Subject: [PATCH] Add test for different `PARTIAL_PARSE_FILE_DIFF` values to `get_full_manifest` --- tests/unit/parser/test_manifest.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unit/parser/test_manifest.py b/tests/unit/parser/test_manifest.py index f5b4c411b4e..72a2db5b6b6 100644 --- a/tests/unit/parser/test_manifest.py +++ b/tests/unit/parser/test_manifest.py @@ -10,6 +10,7 @@ from dbt.contracts.graph.manifest import Manifest from dbt.flags import set_from_args from dbt.parser.manifest import ManifestLoader +from dbt.parser.read_files import FileDiff from dbt.tracking import User @@ -170,3 +171,30 @@ def test_reset( ManifestLoader.get_full_manifest(config=mock_project, reset=True) assert mock_project.clear_dependencies.called assert mock_adapter.clear_macro_resolver.called + + def test_partial_parse_file_diff_flag( + self, + manifest: Manifest, + mock_project: MagicMock, + mock_adapter: MagicMock, + mocker: MockerFixture, + ) -> None: + self.set_required_mocks(mocker, manifest, mock_adapter) + + # FileDiff.from_dict is only called if PARTIAL_PARSE_FILE_DIFF == False + # So we can track this function call to check if setting PARTIAL_PARSE_FILE_DIFF + # works appropriately + mock_file_diff = mocker.patch("dbt.parser.read_files.FileDiff.from_dict") + mock_file_diff.return_value = FileDiff([], [], []) + + set_from_args(Namespace(), {}) + ManifestLoader.get_full_manifest(config=mock_project) + assert not mock_file_diff.called + + set_from_args(Namespace(PARTIAL_PARSE_FILE_DIFF=True), {}) + ManifestLoader.get_full_manifest(config=mock_project) + assert not mock_file_diff.called + + set_from_args(Namespace(PARTIAL_PARSE_FILE_DIFF=False), {}) + ManifestLoader.get_full_manifest(config=mock_project) + assert mock_file_diff.called