Skip to content

Commit

Permalink
Assert warning
Browse files Browse the repository at this point in the history
  • Loading branch information
LennartKloppenburg committed Oct 23, 2023
1 parent 8bd1004 commit 89913c2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
import logging

from unittest.mock import patch
import pytest
Expand All @@ -12,6 +13,7 @@

SAMPLE_PROFILE_YML = Path(__file__).parent / "sample/profiles.yml"
SAMPLE_DBT_PROJECT = Path(__file__).parent / "sample/"
LOGGER = logging.getLogger(__name__)


@pytest.mark.parametrize("argument_key", ["tags", "paths"])
Expand Down Expand Up @@ -67,3 +69,36 @@ def test_converter_creates_dag_with_seed(mock_load_dbt_graph, execution_mode, op
operator_args=operator_args,
)
assert converter

@pytest.mark.parametrize(
"execution_mode,virtualenv_dir,operator_args",
[
(ExecutionMode.KUBERNETES, Path("/some/virtualenv/dir"), {}),
# (ExecutionMode.DOCKER, {"image": "sample-image"}),
],
)
@patch("cosmos.converter.DbtGraph.filtered_nodes", nodes)
@patch("cosmos.converter.DbtGraph.load")
def test_converter_raises_warning(mock_load_dbt_graph, execution_mode, virtualenv_dir, operator_args, caplog):
"""
This test will raise a warning if we are trying to pass ExecutionMode != `VirtualEnv` andm still pass a defined `virtualenv_dir`
"""
project_config = ProjectConfig(dbt_project_path=SAMPLE_DBT_PROJECT)
execution_config = ExecutionConfig(execution_mode=execution_mode, virtualenv_dir=virtualenv_dir)
render_config = RenderConfig(emit_datasets=True)
profile_config = ProfileConfig(
profile_name="my_profile_name",
target_name="my_target_name",
profiles_yml_filepath=SAMPLE_PROFILE_YML,
)
converter = DbtToAirflowConverter(
nodes=nodes,
project_config=project_config,
profile_config=profile_config,
execution_config=execution_config,
render_config=render_config,
operator_args=operator_args,
)

assert "`ExecutionConfig.virtualenv_dir` is only supported when \
ExecutionConfig.execution_mode is set to ExecutionMode.VIRTUALENV." in caplog.text

0 comments on commit 89913c2

Please sign in to comment.