Skip to content

Commit

Permalink
Add test to ensure virtualenv directory will be deleted or persist
Browse files Browse the repository at this point in the history
Related to astronomer#958
  • Loading branch information
kesompochy committed Sep 9, 2024
1 parent e42aeb0 commit a84d16c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/operators/test_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def test_run_command_without_virtualenv_dir(
assert virtualenv_call[0][0][2] == "virtualenv"
assert "pip" in pip_install_call[0][0][0]
assert pip_install_call[0][0][1] == "install"
cosmos_venv_dirs = [
f for f in os.listdir("/tmp") if os.path.isdir(os.path.join("/tmp", f)) and f.startswith("cosmos-venv")
]
assert len(cosmos_venv_dirs) == 0


@patch("cosmos.operators.virtualenv.DbtVirtualenvBaseOperator._release_venv_lock")
Expand Down Expand Up @@ -135,6 +139,10 @@ def test_run_command_with_virtualenv_dir(
assert dbt_cmd["command"][0] == "mock-venv/bin/dbt"
caplog.text.count("Waiting for virtualenv lock to be released") == 2
assert mock_release_venv_lock.called_once()
cosmos_venv_dirs = [
f for f in os.listdir() if f == "mock-venv"
]
assert len(cosmos_venv_dirs) == 1


def test_virtualenv_operator_append_env_is_true_by_default():
Expand Down

0 comments on commit a84d16c

Please sign in to comment.