Skip to content

Commit 10518cd

Browse files
authored
Merge pull request #5 from switchbox-data/fix-tests
Fix tests
2 parents dfd95d1 + 0030aa7 commit 10518cd

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"nefrob.vscode-just-syntax"
1515
],
1616
"settings": {
17+
"python.defaultInterpreterPath": "/workspaces/data-science-project/.venv/bin/python",
1718
"python.testing.pytestArgs": ["tests"],
19+
"python.testing.pytestPath": "/workspaces/data-science-project/.venv/bin/pytest",
1820
"python.testing.unittestEnabled": false,
1921
"python.testing.pytestEnabled": true
2022
}

.devcontainer/postCreateCommand.sh

100644100755
File mode changed.

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ jobs:
2121
enable-cache: 'true'
2222
- name: Install deps
2323
run: uv sync --group dev
24+
- name: Configure git identity
25+
run: |
26+
git config --global user.name "github-actions[bot]"
27+
git config --global user.email "[email protected]"
2428
- name: Run tests
2529
run: uv run pytest -q

tests/test_template.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_python_mkdocs_only(tmp_path: Path) -> None:
152152
# Check that postCreateCommand.sh contains the expected Python setup commands
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")
155-
assert_file_contains(dest, ".devcontainer/postCreateCommand.sh", "uv run pre-commit install --install-hooks")
155+
assert_file_contains(dest, ".devcontainer/postCreateCommand.sh", "prek install --install-hooks")
156156
# Check that Justfile contains documentation commands (python_package boolean bug)
157157
assert_file_contains(dest, "Justfile", "# 📚 DOCUMENTATION")
158158
assert_file_contains(dest, "Justfile", "docs:")
@@ -181,26 +181,24 @@ def test_python_data_science_notebooks(tmp_path: Path) -> None:
181181
},
182182
)
183183
assert res.returncode == 0, res.stderr
184-
assert_exists(
185-
dest, "notebooks", "pyproject.toml", "tox.ini", "pydata_proj", "tests", ".github", ".devcontainer"
186-
)
184+
assert_exists(dest, "notebooks", "pyproject.toml", "tox.ini", "pydata_proj", "tests", ".github", ".devcontainer")
187185
assert_missing(dest, "docs", "mkdocs.yml")
188186
# 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\"")
187+
assert_file_contains(dest, "notebooks/py_example.qmd", 'title: "Python Data Analysis Example"')
190188
assert_file_contains(dest, "notebooks/py_example.qmd", "import polars as pl")
191189
# Ensure template condition is not present in final output
192190
content = (dest / "notebooks/py_example.qmd").read_text()
193-
assert "{% if cookiecutter.pydata == \"y\" %}" not in content, "Template condition should be resolved"
191+
assert '{% if cookiecutter.pydata == "y" %}' not in content, "Template condition should be resolved"
194192

195193

196-
def test_directory_name_in_devcontainer(tmp_path: Path) -> None:
194+
def test_project_name_in_devcontainer(tmp_path: Path) -> None:
197195
dest = tmp_path / "my_custom_dir"
198196
res = run_copier(
199197
Path(__file__).parents[1],
200198
dest,
201199
{
202200
"author": "Test",
203-
"email": "[email protected]",
201+
"email": "[email protected]",
204202
"author_github_handle": "test",
205203
"project_name": "different-name", # This is different from directory name
206204
"project_features": "[python_package]",
@@ -210,8 +208,8 @@ def test_directory_name_in_devcontainer(tmp_path: Path) -> None:
210208
},
211209
)
212210
assert res.returncode == 0, res.stderr
213-
# Check that devcontainer uses actual directory name, not project_name
214-
assert_file_contains(dest, ".devcontainer/devcontainer.json", "/workspaces/my_custom_dir/.venv/bin/python")
215-
# Should NOT contain the project_name in paths
211+
# Check that devcontainer uses project name, not directory name
212+
assert_file_contains(dest, ".devcontainer/devcontainer.json", "/workspaces/different-name")
213+
# Should NOT contain the directory name in paths
216214
content = (dest / ".devcontainer/devcontainer.json").read_text()
217-
assert "/workspaces/different-name/" not in content
215+
assert "/workspaces/my_custom_dir/" not in content

0 commit comments

Comments
 (0)