Added a unit-test for the system check.

This commit is contained in:
Carlton Gibson 2022-08-05 18:41:22 +02:00
parent 09c43f4c81
commit 79abfaeb20
2 changed files with 22 additions and 1 deletions

View File

@ -25,7 +25,7 @@ setup(
install_requires=["twisted[tls]>=22.4", "autobahn>=22.4.2", "asgiref>=3.5.2,<4"],
python_requires=">=3.7",
setup_requires=["pytest-runner"],
extras_require={"tests": ["hypothesis", "pytest", "pytest-asyncio"]},
extras_require={"tests": ["hypothesis", "pytest", "pytest-asyncio", "django"]},
entry_points={
"console_scripts": ["daphne = daphne.cli:CommandLineInterface.entrypoint"]
},

21
tests/test_checks.py Normal file
View File

@ -0,0 +1,21 @@
import django
from django.conf import settings
from django.test.utils import override_settings
from daphne.checks import check_daphne_installed
def test_check_daphne_installed():
"""
Test check error is raised if daphne is not listed before staticfiles, and vice versa.
"""
settings.configure(
INSTALLED_APPS=["daphne.apps.DaphneConfig", "django.contrib.staticfiles"]
)
django.setup()
errors = check_daphne_installed(None)
assert len(errors) == 0
with override_settings(INSTALLED_APPS=["django.contrib.staticfiles", "daphne"]):
errors = check_daphne_installed(None)
assert len(errors) == 1
assert errors[0].id == "daphne.E001"