test_organization_rate_limits.py 1.7 KB

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