Skip to content

Commit

Permalink
Add monkeypatch for remove stage dir confirmation and prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
smokestacklightnin committed Dec 14, 2024
1 parent 473a66a commit 52bfb1f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/tests_unit/test_cli_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest
import yaml
from rich.prompt import Confirm, Prompt
from typer.testing import CliRunner

import _nebari.upgrade
Expand Down Expand Up @@ -450,6 +451,24 @@ def test_cli_upgrade_to_2023_10_1_kubernetes_validations(
"gcp": {"incompatible": "1.23", "compatible": "1.26", "invalid": "badname"},
}

def mock_input_ask(prompt, *args, **kwargs):
from _nebari.upgrade import TERRAFORM_REMOVE_TERRAFORM_STAGE_FILES_CONFIRMATION

# For more about structural pattern matching, see:
# https://peps.python.org/pep-0636/
match prompt:
case str(s) if s == TERRAFORM_REMOVE_TERRAFORM_STAGE_FILES_CONFIRMATION:
return kwargs.get("attempt_fixes", False)
case _:
return kwargs.get("default", False)

monkeypatch.setattr(Confirm, "ask", mock_input_ask)
monkeypatch.setattr(
Prompt,
"ask",
lambda x, *args, **kwargs: "",
)

with tempfile.TemporaryDirectory() as tmp:
tmp_file = Path(tmp).resolve() / "nebari-config.yaml"
assert tmp_file.exists() is False
Expand Down

0 comments on commit 52bfb1f

Please sign in to comment.