class AnonRateThrottleTests(TestCase): def setUp(self): self.throttle = AnonRateThrottle() def test_authenticated_user_not_affected(self): request = Request(HttpRequest()) user = User.objects.create(username='******') force_authenticate(request, user) request.user = user assert self.throttle.get_cache_key(request, view={}) is None def test_get_cache_key_returns_correct_value(self): request = Request(HttpRequest()) cache_key = self.throttle.get_cache_key(request, view={}) assert cache_key == 'throttle_anon_None'
def setUp(self): self.throttle = AnonRateThrottle()