Django Throttle на тестовом сервере
Я работаю над проектом и использую django restframework throttle он работает хорошо при использовании сервера на локальном или производственном сервере, но когда я пытаюсь протестировать конечную точку с помощью testcase он возвращает ошибку
Это мои конфигурации
настройка базы отдыха по умолчанию
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_CLASSES': [
'rest_framework.throttling.AnonRateThrottle',
'rest_framework.throttling.UserRateThrottle',
'rest_framework.throttling.ScopedRateThrottle',
],
'DEFAULT_THROTTLE_RATES': {
"""
anon is for the AnonRateThrottle base on anonymous user
user is for the UserRateThrottle base on logged in user
ScopedRateThrottle this is just used to set custom throttle just like the authentication, monitor below
"""
'anon': '100/min',
'user': '200/min',
# the throttle is the amount of time a user can access a route in a minute
'authentication': '3/min',
# used on route where the user is not logged in like requesting otp
'monitor': '3/min',
},
'DEFAULT_AUTHENTICATION_CLASSES': (
# currently setting the default authentication for django rest framework to jwt
'rest_framework_simplejwt.authentication.JWTAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticatedOrReadOnly',
),
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}
Тестовый пример
def test_verify_and_check_if_profile_created(self):
"""
This test if the user profile was created,
and also it verify the user first
:return:
"""
# checks if the user profile is not none
self.assertIsNotNone(self.user.user_profile)
# request otp for the set-up user
client = APIClient()
client.credentials(HTTP_INSTASAW_SK_HEADER=config('INSTASAW_SK_HEADER'))
request_otp_response = client.post('/api/v1/auth/verify_account/', {
"email": self.user_email,
})
print(request_otp_response.json())
Ошибка
django.core.exceptions.ImproperlyConfigured: No default throttle rate set for 'anon' scope