Skip to content

Commit f0d9453

Browse files
committed
Fix other boolean-related bugs
1 parent 1967c95 commit f0d9453

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

template/Justfile.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test:
3030

3131
{% endif %}
3232

33-
{% if python_package == "y" %}
33+
{% if python_package %}
3434

3535
# =============================================================================
3636
# 📚 DOCUMENTATION

template/{% if python_data_science or r_data_science %}notebooks{% endif %}/{% if python_data_science %}py_example.qmd{% endif %}

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% if cookiecutter.pydata == "y" %}---
1+
{% if python_data_science %}---
22
title: "Python Data Analysis Example"
33
author: "{{cookiecutter.author}}"
44
date: today

template/{% if use_github %}.github{% endif %}/workflows/{% if use_github and python %}main.yml{% endif %}.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Check typing
5454
run: uv run {% if type_checker == "mypy" %}mypy{% else %}ty check{% endif %}
5555

56-
{% if python_package == "y" %}
56+
{% if python_package %}
5757
check-docs:
5858
runs-on: ubuntu-latest
5959
steps:

template/{% if use_github %}.github{% endif %}/workflows/{% if use_github and python %}on-release-main.yml{% endif %}.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
types: [published]
66

77
jobs:
8-
{% if python_package == "y" %}
8+
{% if python_package %}
99
set-version:
1010
runs-on: ubuntu-24.04
1111
steps:

tests/test_template.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,41 @@ def test_python_mkdocs_only(tmp_path: Path) -> None:
153153
assert_file_contains(dest, ".devcontainer/postCreateCommand.sh", "curl -LsSf https://astral.sh/uv/install.sh | sh")
154154
assert_file_contains(dest, ".devcontainer/postCreateCommand.sh", "uv sync --group dev")
155155
assert_file_contains(dest, ".devcontainer/postCreateCommand.sh", "uv run pre-commit install --install-hooks")
156+
# Check that Justfile contains documentation commands (python_package boolean bug)
157+
assert_file_contains(dest, "Justfile", "# 📚 DOCUMENTATION")
158+
assert_file_contains(dest, "Justfile", "docs:")
159+
# Check that GitHub workflow contains docs check job (python_package boolean bug)
160+
assert_file_contains(dest, ".github/workflows/main.yml", "check-docs:")
161+
# Check that release workflow contains set-version job (python_package boolean bug)
162+
assert_file_contains(dest, ".github/workflows/on-release-main.yml", "set-version:")
163+
164+
165+
def test_python_data_science_notebooks(tmp_path: Path) -> None:
166+
dest = tmp_path / "pydata"
167+
res = run_copier(
168+
Path(__file__).parents[1],
169+
dest,
170+
{
171+
"author": "Switchbox",
172+
"email": "hello@switch.box",
173+
"author_github_handle": "switchbox-data",
174+
"project_name": "pydata-proj",
175+
"project_description": "Python data science project",
176+
"type_checker": "ty",
177+
"project_features": "[python_data_science]",
178+
"use_github": True,
179+
"open_source_license": "MIT license",
180+
"aws": False,
181+
},
182+
)
183+
assert res.returncode == 0, res.stderr
184+
assert_exists(
185+
dest, "notebooks", "pyproject.toml", "tox.ini", "pydata_proj", "tests", ".github", ".devcontainer"
186+
)
187+
assert_missing(dest, "docs", "mkdocs.yml")
188+
# Check that py_example.qmd contains actual content (not template condition)
189+
assert_file_contains(dest, "notebooks/py_example.qmd", "title: \"Python Data Analysis Example\"")
190+
assert_file_contains(dest, "notebooks/py_example.qmd", "import polars as pl")
191+
# Ensure template condition is not present in final output
192+
content = (dest / "notebooks/py_example.qmd").read_text()
193+
assert "{% if cookiecutter.pydata == \"y\" %}" not in content, "Template condition should be resolved"

0 commit comments

Comments
 (0)