Skip to content

Commit

Permalink
Feature/check_python (#26)
Browse files Browse the repository at this point in the history
* πŸͺ πŸ’š fix action yml automatic python selection

* πŸ‘· upgrade to 3.11

* βœ… add test to check python version

* ♻️ βœ…  refactor test to no repeat code
  • Loading branch information
JoseRZapata committed Feb 12, 2024
1 parent 36035d5 commit 7e0ecb5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/actions/python-poetry-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
python-version:
required: false
description: 'Python version'
default: '3.10'
default: '3.11'
outputs: {}
runs:
using: 'composite'
Expand Down
15 changes: 8 additions & 7 deletions tests/test_create_template_no_mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ def test_cookiecutter_mkdocs_files(cookies) -> None: # type: ignore
mkdocs = False
result = cookies.bake(extra_context={"mkdocs": mkdocs})

env_path = result.project_path / "mkdocs.yml"
assert not env_path.is_file()
file_paths = [
"mkdocs.yml",
".github/workflows/docs.yml",
"docs/index.md",
]

env_path = result.project_path / ".github/workflows/docs.yml"
assert not env_path.is_file()

env_path = result.project_path / "docs/index.md"
assert not env_path.is_file()
for file_path in file_paths:
env_path = result.project_path / file_path
assert not env_path.is_file()

env_path = result.project_path / "pyproject.toml"
assert env_path.is_file()
Expand Down
19 changes: 19 additions & 0 deletions tests/test_create_template_python_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def test_cookiecutter_python_version(cookies) -> None: # type: ignore
"""check correct python version in the generated files."""
versions = ["3.10", "3.11"]
file_paths = [
".github/actions/python-poetry-env/action.yml",
".github/workflows/test.yml",
"pyproject.toml",
]

for python_ver in versions:
result = cookies.bake(extra_context={"compatible_python_versions": python_ver})

for file_path in file_paths:
env_path = result.project_path / file_path
assert env_path.is_file()

with open(env_path) as f:
file_content = f.read()
assert python_ver in file_content
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: 'Setup Python + Poetry environment'
description: 'Setup Python + Poetry environment'
#{% raw %}

inputs:
python-version:
required: false
description: 'Python version'
default: '3.10'
default: '{{ cookiecutter.compatible_python_versions }}'
outputs: {}
#{% raw %}
runs:
using: 'composite'
steps:
Expand Down

0 comments on commit 7e0ecb5

Please sign in to comment.