This commit adds extensive unit tests across all Django app domains, increasing test coverage significantly. All tests use mocks to avoid database dependencies and follow the testing pyramid approach. Domains covered: - identity/core: mixins, models, permissions, OAuth, quota service - identity/users: models, API views, MFA, services - commerce/tickets: signals, serializers, views, email notifications - commerce/payments: services, views - communication/credits: models, tasks, views - communication/mobile: serializers, views - communication/notifications: models, serializers, views - platform/admin: serializers, views - platform/api: models, views, token security - scheduling/schedule: models, serializers, services, signals, views - scheduling/contracts: serializers, views - scheduling/analytics: views Key improvements: - Fixed 54 previously failing tests in signals and serializers - All tests use proper mocking patterns (no @pytest.mark.django_db) - Added test factories for creating mock objects - Updated conftest.py with shared fixtures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
63 lines
2.1 KiB
Python
63 lines
2.1 KiB
Python
"""
|
|
With these settings, tests run faster.
|
|
"""
|
|
|
|
from .multitenancy import * # noqa: F403
|
|
from .multitenancy import TEMPLATES, env
|
|
|
|
# GENERAL
|
|
# ------------------------------------------------------------------------------
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
|
SECRET_KEY = env(
|
|
"DJANGO_SECRET_KEY",
|
|
default="aESXwQWpusSVR5SFLuhCcVXO5slQ2pUljzw0SGLFI109HqeidikhS7dZMy1GC394",
|
|
)
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#test-runner
|
|
TEST_RUNNER = "django.test.runner.DiscoverRunner"
|
|
|
|
# PASSWORDS
|
|
# ------------------------------------------------------------------------------
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
|
|
# Use fast password hasher for tests (bcrypt is intentionally slow)
|
|
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
|
|
|
|
# EMAIL
|
|
# ------------------------------------------------------------------------------
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
|
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
|
|
|
|
# DEBUGGING FOR TEMPLATES
|
|
# ------------------------------------------------------------------------------
|
|
TEMPLATES[0]["OPTIONS"]["debug"] = True # type: ignore[index]
|
|
|
|
# MEDIA
|
|
# ------------------------------------------------------------------------------
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
|
|
MEDIA_URL = "http://media.testserver/"
|
|
# Your stuff...
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# CHANNELS
|
|
# ------------------------------------------------------------------------------
|
|
# Use in-memory channel layer for tests (no Redis needed)
|
|
CHANNEL_LAYERS = {
|
|
"default": {
|
|
"BACKEND": "channels.layers.InMemoryChannelLayer"
|
|
}
|
|
}
|
|
|
|
# CELERY
|
|
# ------------------------------------------------------------------------------
|
|
# Run tasks synchronously in tests
|
|
CELERY_TASK_ALWAYS_EAGER = True
|
|
CELERY_TASK_EAGER_PROPAGATES = True
|
|
|
|
# CACHES
|
|
# ------------------------------------------------------------------------------
|
|
# Use local memory cache for tests
|
|
CACHES = {
|
|
"default": {
|
|
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
|
|
}
|
|
}
|