test_organization_rate_limits.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from unittest.mock import Mock, patch
  2. from django.utils import timezone
  3. from sentry.testutils import AcceptanceTestCase
  4. class OrganizationRateLimitsTest(AcceptanceTestCase):
  5. def setUp(self):
  6. super().setUp()
  7. self.user = self.create_user("foo@example.com")
  8. self.org = self.create_organization(name="Rowdy Tiger", owner=None)
  9. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  10. self.project = self.create_project(organization=self.org, teams=[self.team], name="Bengal")
  11. self.create_member(user=self.user, organization=self.org, role="owner", teams=[self.team])
  12. self.login_as(self.user)
  13. self.path = f"/organizations/{self.org.slug}/rate-limits/"
  14. @patch("sentry.app.quotas.get_maximum_quota", Mock(return_value=(100, 60)))
  15. def test_with_rate_limits(self):
  16. self.project.update(first_event=timezone.now())
  17. self.browser.get(self.path)
  18. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  19. self.browser.wait_until_test_id("rate-limit-editor")
  20. self.browser.snapshot("organization rate limits with quota")
  21. assert self.browser.element_exists_by_test_id("rate-limit-editor")
  22. @patch("sentry.app.quotas.get_maximum_quota", Mock(return_value=(0, 60)))
  23. def test_without_rate_limits(self):
  24. self.project.update(first_event=timezone.now())
  25. self.browser.get(self.path)
  26. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  27. self.browser.wait_until_test_id("rate-limit-editor")
  28. self.browser.snapshot("organization rate limits without quota")
  29. assert self.browser.element_exists_by_test_id("rate-limit-editor")