test_organization_rate_limits.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 region_silo_test
  5. @region_silo_test
  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. self.browser.snapshot("organization rate limits with quota")
  23. assert self.browser.element_exists_by_test_id("rate-limit-editor")
  24. @patch("sentry.quotas.get_maximum_quota", Mock(return_value=(0, 60)))
  25. def test_without_rate_limits(self):
  26. self.project.update(first_event=timezone.now())
  27. self.browser.get(self.path)
  28. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  29. self.browser.wait_until_test_id("rate-limit-editor")
  30. self.browser.snapshot("organization rate limits without quota")
  31. assert self.browser.element_exists_by_test_id("rate-limit-editor")