Skip to content

Commit

Permalink
test: rendering directories with jinja
Browse files Browse the repository at this point in the history
  • Loading branch information
ch-iv committed Aug 20, 2024
1 parent a5c628f commit 926c478
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
run: pdm install -G:all

- name: Test with Coverage
run: pdm run pytest tests --cov=app --cov-report=xml
run: pdm run pytest tests --cov=litestar_manage --cov-report=xml

- if: matrix.python-version == '3.11'
uses: actions/upload-artifact@v4
Expand Down
13 changes: 12 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ exclude_lines = [
'class .*\bProtocol\):',
'@(abc\.)?abstractmethod',
]
omit = ["*/tests/*"]
omit = ["*/tests/*", "*/litestar_manage/template/*"]
show_missing = true

[tool.coverage.run]
branch = true
omit = ["tests/*"]
omit = ["tests/*", "*/litestar_manage/template/*"]

[tool.pytest.ini_options]
addopts = ["-ra", "--ignore", "migrations"]
Expand Down Expand Up @@ -316,4 +316,5 @@ lint = [
test = [
"pytest>=8.3.2",
"pytest-cov>=5.0.0",
"testfixtures>=8.3.0",
]
3 changes: 3 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pathlib import Path

TEMPLATE_DIR = Path(__file__).parent.parent / "src" / "litestar_manage" / "template"
19 changes: 19 additions & 0 deletions tests/test_renderer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest
from testfixtures import TempDirectory

from litestar_manage.renderer import RenderingContext, _render_jinja_dir
from tests import TEMPLATE_DIR


@pytest.fixture
def rendering_context() -> RenderingContext:
return RenderingContext(app_name="TestApp")


def test_render_jinja_dir(rendering_context: RenderingContext) -> None:
with TempDirectory() as t:
temp_path = t.as_path()
_render_jinja_dir(TEMPLATE_DIR, temp_path, rendering_context)

assert (temp_path / "app").exists()
assert (temp_path / "app" / "app.py").exists()

0 comments on commit 926c478

Please sign in to comment.