Skip to content

Commit

Permalink
Add basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
LennartKloppenburg committed Oct 18, 2023
1 parent 0364ea3 commit 9b94cec
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/operators/test_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,33 @@ def test_run_command(
assert dbt_deps[0][0][0] == dbt_cmd[0][0][0]
assert dbt_cmd[0][0][1] == "do-something"
assert mock_execute.call_count == 2

@patch("airflow.utils.python_virtualenv.execute_in_subprocess")
@patch("cosmos.operators.virtualenv.DbtLocalBaseOperator.calculate_openlineage_events_completes")
@patch("cosmos.operators.virtualenv.DbtLocalBaseOperator.store_compiled_sql")
@patch("cosmos.operators.virtualenv.DbtLocalBaseOperator.exception_handling")
@patch("cosmos.operators.virtualenv.DbtLocalBaseOperator.subprocess_hook")
@patch("airflow.hooks.base.BaseHook.get_connection")
def test_supply_virtualenv_dir_flag(
mock_get_connection,
):
mock_get_connection.return_value = Connection(
conn_id="fake_conn",
conn_type="postgres",
host="fake_host",
port=5432,
login="fake_login",
password="fake_password",
schema="fake_schema",
)
venv_operator = DbtVirtualenvBaseOperator(
profile_config=profile_config,
task_id="fake_task",
install_deps=True,
project_dir="./dev/dags/dbt/jaffle_shop",
py_system_site_packages=False,
py_requirements=["dbt-postgres==1.6.0b1"],
emit_datasets=False,
virtualenv_dir="mock-venv",
)
assert venv_operator.venv_dbt_path == "mock-venv/bin/dbt"

0 comments on commit 9b94cec

Please sign in to comment.