Skip to content

Commit

Permalink
tests(graph): fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cliff-lau-cloverhealth committed Sep 20, 2023
1 parent e24b825 commit 993b707
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/dbt/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def test_load(
@patch("cosmos.dbt.graph.Popen")
def test_load_via_dbt_ls_does_not_create_target_logs_in_original_folder(mock_popen, tmp_dbt_project_dir):
mock_popen().communicate.return_value = ("", "")
mock_popen().returncode = 0
assert not (tmp_dbt_project_dir / "target").exists()
assert not (tmp_dbt_project_dir / "logs").exists()

Expand Down Expand Up @@ -277,8 +278,11 @@ def test_load_via_dbt_ls_without_dbt_deps():


@pytest.mark.integration
@patch("cosmos.dbt.graph.Popen.communicate", return_value=("Some Runtime Error", ""))
def test_load_via_dbt_ls_with_runtime_error_in_stdout(mock_popen_communicate):
@patch("cosmos.dbt.graph.Popen")
def test_load_via_dbt_ls_with_runtime_error_in_stdout(mock_popen):
mock_popen().communicate.return_value = ("Some Runtime Error", "")
mock_popen().returncode = 1

# It may seem strange, but at least until dbt 1.6.0, there are circumstances when it outputs errors to stdout
dbt_project = DbtProject(name="jaffle_shop", root_dir=DBT_PROJECTS_ROOT_DIR)
dbt_graph = DbtGraph(
Expand All @@ -296,7 +300,7 @@ def test_load_via_dbt_ls_with_runtime_error_in_stdout(mock_popen_communicate):
dbt_graph.load_via_dbt_ls()
expected = "Unable to run dbt deps command due to the error:\nSome Runtime Error"
assert err_info.value.args[0] == expected
mock_popen_communicate.assert_called_once()
mock_popen().communicate.assert_called_once()


@pytest.mark.parametrize("pipeline_name", ("jaffle_shop", "jaffle_shop_python"))
Expand Down

0 comments on commit 993b707

Please sign in to comment.