I am working on a project and i am using django restframework throttle it works well when using the server either on local or production but when i tries testing the endpoint using testcase it returns an error
This is my configurations
the default rest framework setting
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_CLASSES': [
'rest_framework.throttling.AnonRateThrottle',
'rest_framework.throttling.UserRateThrottle',
'rest_framework.throttling.ScopedRateThrottle',
],
'DEFAULT_THROTTLE_RATES': {
'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',
}
The test case
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())
The error
django.core.exceptions.ImproperlyConfigured: No default throttle rate set for 'anon' scope