Coverage for app/extensions.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-31 10:13 +0000

1from flask import current_app # pyright: ignore[reportMissingImports] 

2from flask_caching import Cache # pyright: ignore[reportMissingImports] 

3from flask_limiter import Limiter # pyright: ignore[reportMissingImports] 

4from flask_limiter.util import ( 

5 get_remote_address, # pyright: ignore[reportMissingImports] 

6) 

7 

8 

9def _rate_limiting_disabled() -> bool: 

10 """True when RATELIMIT_ENABLED=False — used as exempt_when on route-level limits. 

11 

12 Flask-limiter 4.x does not honour RATELIMIT_ENABLED for per-route @limiter.limit() 

13 decorators (only for the global default). This function makes the exemption explicit 

14 so that test fixtures that set RATELIMIT_ENABLED=False disable all limits correctly. 

15 It is a dict lookup and adds no measurable overhead per request. 

16 """ 

17 return not current_app.config.get("RATELIMIT_ENABLED", True) 

18 

19 

20cache = Cache() 

21 

22limiter = Limiter( 

23 get_remote_address, storage_uri="memory://", default_limits=["200 per minute"] 

24)