This commit is contained in:
parent
51defc11e1
commit
bc075bc95e
6 changed files with 7 additions and 16 deletions
|
|
@ -229,10 +229,9 @@ if DEBUG or TESTING:
|
||||||
MIDDLEWARE.append("zeal.middleware.zeal_middleware")
|
MIDDLEWARE.append("zeal.middleware.zeal_middleware")
|
||||||
|
|
||||||
if not TESTING:
|
if not TESTING:
|
||||||
INSTALLED_APPS = [*INSTALLED_APPS, "debug_toolbar", "silk"]
|
INSTALLED_APPS.append("debug_toolbar")
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
"debug_toolbar.middleware.DebugToolbarMiddleware",
|
"debug_toolbar.middleware.DebugToolbarMiddleware",
|
||||||
"silk.middleware.SilkyMiddleware",
|
|
||||||
*MIDDLEWARE,
|
*MIDDLEWARE,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -316,18 +316,16 @@ def test_debug_tools_installed_only_when_not_testing(
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
reload_settings_module: Callable[..., ModuleType],
|
reload_settings_module: Callable[..., ModuleType],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""`debug_toolbar` and `silk` are only added when not TESTING."""
|
"""`debug_toolbar` is only added when not TESTING."""
|
||||||
# Not testing -> tools should be present
|
# Not testing -> tools should be present
|
||||||
monkeypatch.setattr("sys.argv", ["manage.py", "runserver"])
|
monkeypatch.setattr("sys.argv", ["manage.py", "runserver"])
|
||||||
monkeypatch.delenv("PYTEST_VERSION", raising=False)
|
monkeypatch.delenv("PYTEST_VERSION", raising=False)
|
||||||
not_testing: ModuleType = reload_settings_module(TESTING=None, PYTEST_VERSION=None)
|
not_testing: ModuleType = reload_settings_module(TESTING=None, PYTEST_VERSION=None)
|
||||||
assert "debug_toolbar" in not_testing.INSTALLED_APPS
|
assert "debug_toolbar" in not_testing.INSTALLED_APPS
|
||||||
assert "silk" in not_testing.INSTALLED_APPS
|
|
||||||
|
|
||||||
# Testing -> tools should not be present
|
# Testing -> tools should not be present
|
||||||
testing: ModuleType = reload_settings_module(PYTEST_VERSION="7.0.0")
|
testing: ModuleType = reload_settings_module(PYTEST_VERSION="7.0.0")
|
||||||
assert "debug_toolbar" not in testing.INSTALLED_APPS
|
assert "debug_toolbar" not in testing.INSTALLED_APPS
|
||||||
assert "silk" not in testing.INSTALLED_APPS
|
|
||||||
|
|
||||||
|
|
||||||
def test_logging_configuration_structure() -> None:
|
def test_logging_configuration_structure() -> None:
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,10 @@ def test_top_level_named_routes_available() -> None:
|
||||||
|
|
||||||
|
|
||||||
def test_debug_tools_not_present_while_testing() -> None:
|
def test_debug_tools_not_present_while_testing() -> None:
|
||||||
"""`silk` and Django Debug Toolbar URL patterns are not present while running tests."""
|
"""Django Debug Toolbar URL patterns are not present while running tests."""
|
||||||
# Default test environment should *not* expose debug routes.
|
# Default test environment should *not* expose debug routes.
|
||||||
mod = _reload_urls_with(TESTING=True)
|
mod = _reload_urls_with(TESTING=True)
|
||||||
patterns = list(_pattern_strings(mod))
|
patterns = list(_pattern_strings(mod))
|
||||||
assert not any("silk" in p for p in patterns)
|
|
||||||
assert not any("__debug__" in p or "debug" in p for p in patterns)
|
assert not any("__debug__" in p or "debug" in p for p in patterns)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -90,8 +89,7 @@ def test_media_serving_in_development() -> None:
|
||||||
assert any("MEDIA_URL" in str(pattern) for pattern in urlpatterns)
|
assert any("MEDIA_URL" in str(pattern) for pattern in urlpatterns)
|
||||||
|
|
||||||
|
|
||||||
def test_debug_toolbar_and_silk_urls() -> None:
|
def test_debug_toolbar_urls() -> None:
|
||||||
"""Test that debug toolbar and Silk URLs are included when appropriate."""
|
"""Test that debug toolbar URLs are included when appropriate."""
|
||||||
if not settings.TESTING:
|
if not settings.TESTING:
|
||||||
assert any("silk.urls" in str(pattern) for pattern in urlpatterns)
|
|
||||||
assert any("debug_toolbar" in str(pattern) for pattern in urlpatterns)
|
assert any("debug_toolbar" in str(pattern) for pattern in urlpatterns)
|
||||||
|
|
|
||||||
|
|
@ -62,5 +62,4 @@ if settings.DEBUG:
|
||||||
if not settings.TESTING:
|
if not settings.TESTING:
|
||||||
from debug_toolbar.toolbar import debug_toolbar_urls
|
from debug_toolbar.toolbar import debug_toolbar_urls
|
||||||
|
|
||||||
urlpatterns += [path("silk/", include("silk.urls", namespace="silk"))]
|
|
||||||
urlpatterns = [*urlpatterns, *debug_toolbar_urls()]
|
urlpatterns = [*urlpatterns, *debug_toolbar_urls()]
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ dependencies = [
|
||||||
"django-celery-results",
|
"django-celery-results",
|
||||||
"django-debug-toolbar",
|
"django-debug-toolbar",
|
||||||
"django-ninja",
|
"django-ninja",
|
||||||
"django-silk",
|
|
||||||
"django-zeal",
|
"django-zeal",
|
||||||
"django",
|
"django",
|
||||||
"flower",
|
"flower",
|
||||||
|
|
|
||||||
|
|
@ -109,11 +109,10 @@ class TestBackupCommand:
|
||||||
):
|
):
|
||||||
content: str = handle.read()
|
content: str = handle.read()
|
||||||
|
|
||||||
# Should NOT contain django admin, silk, or debug toolbar tables
|
# Should NOT contain django admin or debug toolbar tables
|
||||||
assert "django_session" not in content
|
assert "django_session" not in content
|
||||||
assert "django_migrations" not in content
|
assert "django_migrations" not in content
|
||||||
assert "django_content_type" not in content
|
assert "django_content_type" not in content
|
||||||
assert "silk_" not in content
|
|
||||||
assert "debug_toolbar_" not in content
|
assert "debug_toolbar_" not in content
|
||||||
assert "django_admin_log" not in content
|
assert "django_admin_log" not in content
|
||||||
assert "auth_" not in content
|
assert "auth_" not in content
|
||||||
|
|
@ -215,9 +214,8 @@ class TestBackupHelperFunctions:
|
||||||
# Use Django's connection to access the test database
|
# Use Django's connection to access the test database
|
||||||
tables = _get_allowed_tables("twitch_")
|
tables = _get_allowed_tables("twitch_")
|
||||||
|
|
||||||
# Should not include django, silk, or debug toolbar tables
|
# Should not include django or debug toolbar tables
|
||||||
assert not any(table.startswith("django_") for table in tables)
|
assert not any(table.startswith("django_") for table in tables)
|
||||||
assert not any(table.startswith("silk_") for table in tables)
|
|
||||||
assert not any(table.startswith("debug_toolbar_") for table in tables)
|
assert not any(table.startswith("debug_toolbar_") for table in tables)
|
||||||
|
|
||||||
def test_sql_literal_handles_none(self) -> None:
|
def test_sql_literal_handles_none(self) -> None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue