def test_process_event_exists(
        self, mock_objects, mock__create_from_stripe_object, mock_atomic
    ):
        """
        Test that process event returns the existing event and skips webhook processing
        when the event already exists.
        """
        # Set up mocks
        mock_objects.filter.return_value.exists.return_value = True
        mock_data = {"id": "foo_id", "other_stuff": "more_things"}

        result = Event.process(data=mock_data)

        # Make sure that the db was queried and the existing results used.
        mock_objects.filter.assert_called_once_with(id=mock_data["id"])
        mock_objects.filter.return_value.exists.assert_called_once_with()
        mock_objects.filter.return_value.first.assert_called_once_with()
        # Make sure the webhook actions and event object creation were not performed.
        mock_atomic.return_value.__enter__.assert_not_called()
        mock__create_from_stripe_object.assert_not_called()
        (
            mock__create_from_stripe_object.return_value.invoke_webhook_handlers
        ).assert_not_called()
        # Make sure the existing event was returned.
        self.assertEqual(mock_objects.filter.return_value.first.return_value, result)

        Test that process event returns the existing event and skips webhook processing
        when the event already exists.
        
tests/test_event.py