from django.test import override_settings, TestCase


class RateLimitTest(TestCase):
    def setUp(self):
        self.url = "/server/checkratelimit/"

    @override_settings(RATELIMIT_ENABLE=True)
    def test_checkView_rateLimitAfter5Requests(self):
        for i in range(10):
            response = self.client.get(self.url)

            if i < 5:
                self.assertEqual(response.status_code, 200)
            else:
                # der 6. Zugriff wird gesperrt
                self.assertEqual(response.status_code, 429)
