diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..5575ad5 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.10-slim + +WORKDIR /app + +# Install git and other potential dependencies +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt requirements-dev.txt ./ +RUN pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt + +COPY . . + +CMD ["pytest"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..bd2e116 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,14 @@ +{ + "name": "ItsPrompt Dev", + "build": { + "dockerfile": "Dockerfile" + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance" + ] + } + } +} diff --git a/tests/data/test_expand.py b/tests/data/test_expand.py index 09a3da6..e453300 100644 --- a/tests/data/test_expand.py +++ b/tests/data/test_expand.py @@ -86,3 +86,10 @@ def test_process_data_with_separator(): ans = process_data(options) assert ans.with_separators == result + + +def test_expand_options_get_option_returns_none(): + options = ("first", "second") + ans = process_data(options) + + assert ans.get_option("z") is None diff --git a/tests/prompts/test_checkbox_prompt.py b/tests/prompts/test_checkbox_prompt.py index fd85a8e..74a0565 100644 --- a/tests/prompts/test_checkbox_prompt.py +++ b/tests/prompts/test_checkbox_prompt.py @@ -96,4 +96,14 @@ def test_checkbox_raises_invalid_disabled(): ans = Prompt.checkbox("", options, disabled=("invalid",)) +def test_checkbox_min_selections(send_keys): + options = ("first", "second") + # Try to enter without selection (blocked), then select "first", then enter (success) + send_keys(Keys.Enter, " ", Keys.Enter) + + ans = Prompt.checkbox("", options, min_selections=1) + + assert ans == ["first"] + + # TODO check min selections with error box (visual) diff --git a/tests/prompts/test_input_prompt.py b/tests/prompts/test_input_prompt.py index 4a9ff83..9567d2a 100644 --- a/tests/prompts/test_input_prompt.py +++ b/tests/prompts/test_input_prompt.py @@ -76,6 +76,16 @@ def test_input_raises_keyboard_interrupt(send_keys): ans = Prompt.input("") +def test_input_validation(send_keys): + # validator requires at least 2 characters + # send "v", Enter (blocked), "a", Enter (success) + send_keys("v", Keys.Enter, "a", Keys.Enter) + + ans = Prompt.input("", validate=lambda x: len(x) > 1) + + assert ans == "va" + + # TODO input show_symbol is showing symbol (visual) # TODO input completer/completions is working (visual, functional) # TODO input validation is showing error (visual)