From f0451fcde525d4dba879119fbad46b717c9e6ba1 Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Wed, 19 Jun 2024 01:01:11 +0200 Subject: [PATCH 1/2] Add original author to package metadata --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 125a739..601d361 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,7 @@ readme = "README.rst" license = {file = "LICENSE"} authors = [ {name = "Peter Bittner", email = "django@bittner.it"}, + {name = "Derek Stegelman ", email = "dstegelman@gmail.com"}, ] maintainers = [ {name = "Peter Bittner", email = "django@bittner.it"}, From a17876c0b51354268c1c9863a4b42c688effaa00 Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Wed, 19 Jun 2024 02:06:54 +0200 Subject: [PATCH 2/2] Add tests for Django templates --- pyproject.toml | 4 ++++ tests/test_project/settings.py | 22 ++++++++++++++++++++++ tests/test_templates.py | 33 +++++++++++++++++++++++++++++++++ tox.ini | 7 +++++-- 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 tests/test_project/settings.py create mode 100644 tests/test_templates.py diff --git a/pyproject.toml b/pyproject.toml index 601d361..fb556c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,10 @@ source = "https://github.com/bittner/django-bootstrap-static" [tool.pytest.ini_options] addopts = "--color=yes --doctest-modules --verbose" +python_files = ["tests.py", "test_*.py", "*_tests.py"] +pythonpath = ["tests"] +DJANGO_SETTINGS_MODULE = "test_project.settings" +FAIL_INVALID_TEMPLATE_VARS = true [tool.ruff] extend-exclude = [] diff --git a/tests/test_project/settings.py b/tests/test_project/settings.py new file mode 100644 index 0000000..1426cf4 --- /dev/null +++ b/tests/test_project/settings.py @@ -0,0 +1,22 @@ +"""Minimal Django settings for test project.""" + +INSTALLED_APPS = [ + "django.contrib.staticfiles", + "bootstrap", + "fontawesome", +] + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.request", + ], + }, + }, +] + +STATIC_URL = "static" diff --git a/tests/test_templates.py b/tests/test_templates.py new file mode 100644 index 0000000..beaf59b --- /dev/null +++ b/tests/test_templates.py @@ -0,0 +1,33 @@ +"""Tests for Django templates.""" + +from django.template import Context, Template + +template = """ + {% load static %} + + + + + + ... + + + +""" + + +def test_template(): + """Importing the package should work as described in the README.""" + bootstrap_min_css = "bootstrap/css/bootstrap.min.css" + bootstrap_min_js = "bootstrap/js/bootstrap.bundle.min.js" + fontawesome_min_js = "fontawesome/js/all.min.js" + jquery_min_js = "bootstrap/js/jquery.min.js" + + c = Context() + t = Template(template) + html = t.render(c) + + assert f'' in html + assert f'' in html + assert f'' in html + assert f'' in html diff --git a/tox.ini b/tox.ini index f317465..ebbfe7a 100644 --- a/tox.ini +++ b/tox.ini @@ -6,8 +6,11 @@ envlist = [testenv] description = Unit tests and test coverage -deps = pytest -commands = pytest {posargs} +deps = + django + pytest-django +commands = + pytest {posargs} [testenv:clean] description = Remove bytecode and other debris