def test__get_redis_url_for_cache(self): examples = [ ("redis://redis:6789", f"redis://redis:6789/{REDIS_CACHE_DB_NUMBER}"), ( "redis://redis.example.com/path/to/thing:6789", f"redis://redis.example.com/path/to/thing:6789/{REDIS_CACHE_DB_NUMBER}", ), ] for input_, expected in examples: with mock.patch( "developerportal.apps.common.settings_helpers.os.environ.get" ) as mock_environ_get: mock_environ_get.return_value = input_ self.assertEqual( _get_redis_url_for_cache(REDIS_CACHE_DB_NUMBER), expected)
# Celery settings CELERY_BROKER_URL = os.environ.get("REDIS_URL", "redis://redis:6379") CELERY_RESULT_BACKEND = "django-db" # for django-celery-results CELERY_ACCEPT_CONTENT = ["application/json"] CELERY_TASK_SERIALIZER = "json" CELERY_RESULT_SERIALIZER = "json" CELERY_TIMEZONE = "UTC" CELERY_ENABLE_UTC = True REDIS_CACHE_DB_NUMBER = os.environ.get("REDIS_CACHE_DB_NUMBER", "1") CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": _get_redis_url_for_cache(REDIS_CACHE_DB_NUMBER), "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient" }, } } CACHE_TIME_TINY = 60 * 5 # 5 mins CACHE_TIME_SHORT = 60 * 60 # 1 hour CACHE_TIME_MEDIUM = 60 * 60 * 24 # 1 day CACHE_TIME_LONG = 60 * 60 * 24 * 7 # 1 week CACHE_TIME_VERY_LONG = 60 * 60 * 24 * 28 # 28 days # Mozilla OpenID Connect / Auth0 configuration OIDC_RP_SIGN_ALGO = "RS256"