diff --git a/tests/test_throttling.py b/tests/test_throttling.py index 84304549c..4937aa7ae 100644 --- a/tests/test_throttling.py +++ b/tests/test_throttling.py @@ -186,10 +186,7 @@ def test_throttle_auth(): set_throttle_timer(th, 2) assert th.allow_request(request) is True - assert ( - th.get_cache_key(request) - == "throttle_auth_a6b46dd0d1ae5e86cbc8f37e75ceeb6760230c1ca4ffbcb0c97b96dd7d9c464b" - ) + assert th.get_cache_key(request) == "throttle_auth_a6b46dd0d1ae5e86cbc8f37e75ceeb6760230c1ca4ffbcb0c97b96dd7d9c464b" def test_throttle_user(): @@ -212,9 +209,7 @@ def test_throttle_user(): request.user.is_authenticated = False assert th.allow_request(request) is True assert th.allow_request(request) is False - assert ( - th.get_cache_key(request) == "throttle_user_8.8.8.8" - ) # not authenticated throttled by IP + assert th.get_cache_key(request) == "throttle_user_8.8.8.8" # not authenticated throttled by IP def test_wait(): @@ -267,6 +262,9 @@ def test_rate_parser(): assert th.parse_rate("10_000/7d") == (10000, 86400 * 7) assert th.parse_rate("10_000/7day") == (10000, 86400 * 7) + with pytest.raises(ValueError): + th.parse_rate("42") + def test_proxy_throttle(): from ninja.conf import settings