Beispiel #1
0
    def test_throws_when_matches_discarded_hash(self):
        manager = EventManager(make_event(message="foo", event_id="a" * 32, fingerprint=["a" * 32]))
        with self.tasks():
            event = manager.save(1)

        group = Group.objects.get(id=event.group_id)
        tombstone = GroupTombstone.objects.create(
            project_id=group.project_id,
            level=group.level,
            message=group.message,
            culprit=group.culprit,
            data=group.data,
            previous_group_id=group.id,
        )
        GroupHash.objects.filter(group=group).update(group=None, group_tombstone_id=tombstone.id)

        manager = EventManager(make_event(message="foo", event_id="b" * 32, fingerprint=["a" * 32]))

        mock_event_discarded = mock.Mock()
        event_discarded.connect(mock_event_discarded)
        mock_event_saved = mock.Mock()
        event_saved.connect(mock_event_saved)

        with self.tasks():
            with self.assertRaises(HashDiscarded):
                event = manager.save(1)

        assert not mock_event_saved.called
        assert_mock_called_once_with_partial(
            mock_event_discarded, project=group.project, sender=EventManager, signal=event_discarded
        )
Beispiel #2
0
    def test_event_saved_signal(self):
        mock_event_saved = mock.Mock()
        event_saved.connect(mock_event_saved)

        manager = EventManager(make_event(message="foo"))
        manager.normalize()
        event = manager.save(1)

        assert_mock_called_once_with_partial(
            mock_event_saved, project=event.group.project, sender=EventManager, signal=event_saved
        )
Beispiel #3
0
    def test_throws_when_matches_discarded_hash(self):
        manager = EventManager(
            self.make_event(
                message='foo',
                event_id='a' * 32,
                fingerprint=['a' * 32],
            )
        )
        with self.tasks():
            event = manager.save(1)

        group = Group.objects.get(id=event.group_id)
        tombstone = GroupTombstone.objects.create(
            project_id=group.project_id,
            level=group.level,
            message=group.message,
            culprit=group.culprit,
            data=group.data,
            previous_group_id=group.id,
        )
        GroupHash.objects.filter(
            group=group,
        ).update(
            group=None,
            group_tombstone_id=tombstone.id,
        )

        manager = EventManager(
            self.make_event(
                message='foo',
                event_id='b' * 32,
                fingerprint=['a' * 32],
            )
        )

        mock_event_discarded = mock.Mock()
        event_discarded.connect(mock_event_discarded)
        mock_event_saved = mock.Mock()
        event_saved.connect(mock_event_saved)

        with self.tasks():
            with self.assertRaises(HashDiscarded):
                event = manager.save(1)

        assert not mock_event_saved.called
        assert_mock_called_once_with_partial(
            mock_event_discarded,
            project=group.project,
            sender=EventManager,
            signal=event_discarded,
        )
Beispiel #4
0
    def test_event_saved_signal(self):
        mock_event_saved = mock.Mock()
        event_saved.connect(mock_event_saved)

        manager = EventManager(self.make_event(message='foo'))
        manager.normalize()
        event = manager.save(1)

        assert_mock_called_once_with_partial(
            mock_event_saved,
            project=event.group.project,
            sender=EventManager,
            signal=event_saved,
        )
    def __init__(self, kafka_producer, kafka_admin, task_runner):
        self.events_filtered = []
        self.events_discarded = []
        self.events_dropped = []
        self.events_saved = []

        event_filtered.connect(self._event_filtered_receiver)
        event_discarded.connect(self._event_discarded_receiver)
        event_dropped.connect(self._event_dropped_receiver)
        event_saved.connect(self._event_saved_receiver)

        self.task_runner = task_runner
        self.topic_name = settings.KAFKA_OUTCOMES
        self.organization = Factories.create_organization()
        self.project = Factories.create_project(organization=self.organization)

        self.producer = self._create_producer(kafka_producer, kafka_admin)