Coverage for conf/settings/thumbnails.py: 100%
11 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 06:14 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 06:14 +0000
1from datetime import timedelta
3from decouple import config
6# If key is not present then the authentication header won't be sent
7# and query forwarding will not work as expected. Lack of query forwarding
8# is not an issue for local development so this compromise is okay.
9PHOTON_AUTH_KEY = config("PHOTON_AUTH_KEY", default=None)
11# Produce CC-hosted thumbnails dynamically through a proxy.
12PHOTON_ENDPOINT = config("PHOTON_ENDPOINT", default="https://i0.wp.com/")
14# These do not need to be cast to int because we don't use them directly,
15# they're just passed through to Photon's API
16# Keeping them as strings makes the tests slightly less verbose (for not needing
17# to cast them in assertions to match the parsed param types)
18THUMBNAIL_WIDTH_PX = config("THUMBNAIL_WIDTH_PX", default="600", cast=int)
19THUMBNAIL_QUALITY = config("THUMBNAIL_JPG_QUALITY", default="80")
21# The length of time to cache repeated thumbnail failures
22THUMBNAIL_FAILURE_CACHE_WINDOW_SECONDS = config(
23 "THUMBNAIL_FAILURE_CACHE_WINDOW_SECONDS",
24 default=int(timedelta(days=2).total_seconds()),
25 cast=int,
26)
28# The number of times to try a thumbnail request before caching a failure
29THUMBNAIL_FAILURE_CACHE_TOLERANCE = config(
30 "THUMBNAIL_FAILURE_CACHE_TOLERANCE", default=2, cast=int
31)
33# Timeout when requesting the thumbnail from the upstream image proxy
34THUMBNAIL_UPSTREAM_TIMEOUT = config("THUMBNAIL_UPSTREAM_TIMEOUT", default=4, cast=int)
36# Timeout when trying to determine the filetype based on a HEAD request to the upstream image provider
37THUMBNAIL_EXTENSION_REQUEST_TIMEOUT = config(
38 "THUMBNAIL_EXTENSION_REQUEST_TIMEOUT", default=4, cast=int
39)
41# Use Wikimedia's thumbnail endpoint when requesting thumbnails from Site Accelerator (formerly Photon)
42USE_WIKIMEDIA_THUMBNAIL_ENDPOINT = config(
43 "USE_WIKIMEDIA_THUMBNAIL_ENDPOINT", default=True, cast=bool
44)