test_signals.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from unittest.mock import patch
  2. from django.utils import timezone
  3. from sentry.signals import issue_mark_reviewed, issue_unignored
  4. from sentry.testutils.cases import SnubaTestCase, TestCase
  5. class SignalsTest(TestCase, SnubaTestCase):
  6. def setUp(self):
  7. super().setUp()
  8. self.now = timezone.now()
  9. self.owner = self.create_user()
  10. self.organization = self.create_organization(owner=self.owner)
  11. self.team = self.create_team(organization=self.organization)
  12. self.project = self.create_project(teams=[self.team])
  13. @patch("sentry.analytics.record")
  14. def test_unignored_manually(self, mock_record):
  15. issue_unignored.send(
  16. project=self.project,
  17. group=self.group,
  18. user_id=self.owner.id,
  19. transition_type="manual",
  20. sender=type(self.project),
  21. )
  22. assert mock_record.called
  23. @patch("sentry.analytics.record")
  24. def test_unignored_automatically(self, mock_record):
  25. issue_unignored.send(
  26. project=self.project,
  27. group=self.group,
  28. user_id=None,
  29. transition_type="automatic",
  30. sender="clear_expired_snoozes",
  31. )
  32. assert mock_record.called
  33. @patch("sentry.analytics.record")
  34. def test_mark_reviewed(self, mock_record):
  35. issue_mark_reviewed.send(
  36. project=self.project, group=self.group, user=None, sender="test_mark_reviewed"
  37. )
  38. assert mock_record.called