From 0367a8c6f5de7e7f5d9c29fd1f9a2b09a71f2247 Mon Sep 17 00:00:00 2001 From: Tatiana Al-Chueyr Date: Wed, 25 Oct 2023 17:07:43 +0100 Subject: [PATCH] Add tests to cover change --- tests/dbt/test_graph.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/dbt/test_graph.py b/tests/dbt/test_graph.py index f176fa445..3927bbfdd 100644 --- a/tests/dbt/test_graph.py +++ b/tests/dbt/test_graph.py @@ -82,12 +82,10 @@ def test_load_automatic_manifest_is_available(mock_load_from_dbt_manifest): assert mock_load_from_dbt_manifest.called -@patch("cosmos.dbt.graph.DbtGraph.load_via_custom_parser", side_effect=FileNotFoundError()) +@patch("cosmos.dbt.graph.DbtGraph.load_via_custom_parser", side_effect=None) @patch("cosmos.dbt.graph.DbtGraph.load_via_dbt_ls", return_value=None) -def test_load_automatic_without_manifest(mock_load_via_dbt_ls, mock_load_via_custom_parser): - project_config = ProjectConfig( - dbt_project_path=DBT_PROJECTS_ROOT_DIR / DBT_PROJECT_NAME, manifest_path="/tmp/manifest.json" - ) +def test_load_automatic_without_manifest_with_profile_yml(mock_load_via_dbt_ls, mock_load_via_custom_parser): + project_config = ProjectConfig(dbt_project_path=DBT_PROJECTS_ROOT_DIR / DBT_PROJECT_NAME) profile_config = ProfileConfig( profile_name="test", target_name="test", @@ -99,6 +97,24 @@ def test_load_automatic_without_manifest(mock_load_via_dbt_ls, mock_load_via_cus assert not mock_load_via_custom_parser.called +@patch("cosmos.dbt.graph.DbtGraph.load_via_custom_parser", side_effect=None) +@patch("cosmos.dbt.graph.DbtGraph.load_via_dbt_ls", return_value=None) +def test_load_automatic_without_manifest_with_profile_mapping(mock_load_via_dbt_ls, mock_load_via_custom_parser): + project_config = ProjectConfig(dbt_project_path=DBT_PROJECTS_ROOT_DIR / DBT_PROJECT_NAME) + profile_config = ProfileConfig( + profile_name="test", + target_name="test", + profile_mapping=PostgresUserPasswordProfileMapping( + conn_id="airflow_db", + profile_args={"schema": "public"}, + ), + ) + dbt_graph = DbtGraph(project=project_config, profile_config=profile_config) + dbt_graph.load(execution_mode=ExecutionMode.LOCAL) + assert mock_load_via_dbt_ls.called + assert not mock_load_via_custom_parser.called + + @patch("cosmos.dbt.graph.DbtGraph.load_via_custom_parser", return_value=None) @patch("cosmos.dbt.graph.DbtGraph.load_via_dbt_ls", side_effect=FileNotFoundError()) def test_load_automatic_without_manifest_and_without_dbt_cmd(mock_load_via_dbt_ls, mock_load_via_custom_parser):