Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CustomScopedRateThrolle throttling class #2689

Merged
merged 4 commits into from
Aug 30, 2024

Conversation

FrankApiyo
Copy link
Member

This will throttle anonymous enketo users more fairly

Changes / Features implemented

Steps taken to verify this change does what is intended

Side effects of implementing this change

Before submitting this PR for review, please make sure you have:

  • Included tests
  • Updated documentation

Closes #

@FrankApiyo FrankApiyo force-pushed the fair-throttling-for-enketo-users branch 2 times, most recently from a00ed0a to 6ebb4cf Compare August 30, 2024 10:52
@FrankApiyo FrankApiyo marked this pull request as ready for review August 30, 2024 10:53
@FrankApiyo FrankApiyo force-pushed the fair-throttling-for-enketo-users branch from 6ebb4cf to ecf661b Compare August 30, 2024 11:09
@FrankApiyo FrankApiyo force-pushed the fair-throttling-for-enketo-users branch from e7db607 to 73c8575 Compare August 30, 2024 12:17
kelvin-muchiri
kelvin-muchiri previously approved these changes Aug 30, 2024
@FrankApiyo FrankApiyo force-pushed the fair-throttling-for-enketo-users branch from 11816da to 880875e Compare August 30, 2024 12:29
kelvin-muchiri
kelvin-muchiri previously approved these changes Aug 30, 2024
self.factory = APIRequestFactory()
self.throttle = CustomScopedRateThrottle()

def test_anonymous_users_get_throttled_based_on_uri_path(self):
Copy link
Contributor

@kelvin-muchiri kelvin-muchiri Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FrankApiyo One trick to make test names shorter is to make use of a docstring e.g

def test_anonymous_users(self):
    """Anonymous users are throttled base on URI path"""
    pass

def test_authenticated_users(self):
    """Authenticated users throttled base on user ID"""

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@FrankApiyo FrankApiyo merged commit a69d9f2 into main Aug 30, 2024
10 checks passed
@FrankApiyo FrankApiyo deleted the fair-throttling-for-enketo-users branch August 30, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants