test_transactions.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from __future__ import absolute_import
  2. from exam import fixture
  3. from sentry.models import Project
  4. from sentry.signals import event_processed
  5. from sentry.testutils import TestCase
  6. from sentry.testutils.helpers.datetime import before_now, iso_format
  7. class RecordFirstTransactionTest(TestCase):
  8. @fixture
  9. def min_ago(self):
  10. return iso_format(before_now(minutes=1))
  11. def test_transaction_processed(self):
  12. assert not self.project.flags.has_transactions
  13. event = self.store_event(
  14. data={
  15. "type": "transaction",
  16. "timestamp": self.min_ago,
  17. "start_timestamp": self.min_ago,
  18. "contexts": {"trace": {"trace_id": "b" * 32, "span_id": "c" * 16, "op": ""}},
  19. },
  20. project_id=self.project.id,
  21. )
  22. event_processed.send(project=self.project, event=event, sender=type(self.project))
  23. project = Project.objects.get(id=self.project.id)
  24. assert project.flags.has_transactions
  25. def test_transaction_processed_no_platform(self):
  26. assert not self.project.flags.has_transactions
  27. event = self.store_event(
  28. data={
  29. "type": "transaction",
  30. "platform": None,
  31. "timestamp": self.min_ago,
  32. "start_timestamp": self.min_ago,
  33. "contexts": {"trace": {"trace_id": "b" * 32, "span_id": "c" * 16, "op": ""}},
  34. },
  35. project_id=self.project.id,
  36. )
  37. event_processed.send(project=self.project, event=event, sender=type(self.project))
  38. project = Project.objects.get(id=self.project.id)
  39. assert project.flags.has_transactions
  40. def test_event_processed(self):
  41. assert not self.project.flags.has_transactions
  42. event = self.store_event(
  43. data={"type": "default", "timestamp": self.min_ago}, project_id=self.project.id
  44. )
  45. event_processed.send(project=self.project, event=event, sender=type(self.project))
  46. project = Project.objects.get(id=self.project.id)
  47. assert not project.flags.has_transactions