test_organization_rate_limits.py 1.6 KB

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