mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 06:51:08 -05:00
Refactor test utilities and enhance ASGI settings
- Cleaned up and standardized assertions in ApiTestMixin for API response validation. - Updated ASGI settings to use os.environ for setting the DJANGO_SETTINGS_MODULE. - Removed unused imports and improved formatting in settings.py. - Refactored URL patterns in urls.py for better readability and organization. - Enhanced view functions in views.py for consistency and clarity. - Added .flake8 configuration for linting and style enforcement. - Introduced type stubs for django-environ to improve type checking with Pylance.
This commit is contained in:
@@ -9,17 +9,17 @@ DEBUG = False
|
||||
|
||||
# Use in-memory database for faster tests
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
|
||||
'NAME': ':memory:',
|
||||
"default": {
|
||||
"ENGINE": "django.contrib.gis.db.backends.spatialite",
|
||||
"NAME": ":memory:",
|
||||
}
|
||||
}
|
||||
|
||||
# Use in-memory cache for tests
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
'LOCATION': 'test-cache',
|
||||
"default": {
|
||||
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
|
||||
"LOCATION": "test-cache",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,28 +37,28 @@ class DisableMigrations:
|
||||
MIGRATION_MODULES = DisableMigrations()
|
||||
|
||||
# Email backend for tests
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
|
||||
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
|
||||
|
||||
# Password hashers for faster tests
|
||||
PASSWORD_HASHERS = [
|
||||
'django.contrib.auth.hashers.MD5PasswordHasher',
|
||||
"django.contrib.auth.hashers.MD5PasswordHasher",
|
||||
]
|
||||
|
||||
# Disable logging during tests
|
||||
LOGGING_CONFIG = None
|
||||
|
||||
# Media files for tests
|
||||
MEDIA_ROOT = BASE_DIR / 'test_media'
|
||||
MEDIA_ROOT = BASE_DIR / "test_media"
|
||||
|
||||
# Static files for tests
|
||||
STATIC_ROOT = BASE_DIR / 'test_static'
|
||||
STATIC_ROOT = BASE_DIR / "test_static"
|
||||
|
||||
# Disable Turnstile for tests
|
||||
TURNSTILE_SITE_KEY = 'test-key'
|
||||
TURNSTILE_SECRET_KEY = 'test-secret'
|
||||
TURNSTILE_SITE_KEY = "test-key"
|
||||
TURNSTILE_SECRET_KEY = "test-secret"
|
||||
|
||||
# Test-specific middleware (remove caching middleware)
|
||||
MIDDLEWARE = [m for m in MIDDLEWARE if 'cache' not in m.lower()]
|
||||
MIDDLEWARE = [m for m in MIDDLEWARE if "cache" not in m.lower()]
|
||||
|
||||
# Celery settings for tests (if Celery is used)
|
||||
CELERY_TASK_ALWAYS_EAGER = True
|
||||
|
||||
Reference in New Issue
Block a user