def test_process_event(
        self, mock_objects, mock__create_from_stripe_object, mock_atomic
    ):
        """Test that process event creates a new event and invokes webhooks
        when the event doesn't already exist.
        """
        # Set up mocks
        mock_objects.filter.return_value.exists.return_value = False
        mock_data = {"id": "foo_id", "other_stuff": "more_things"}

        result = Event.process(data=mock_data)

        # Check that all the expected work was performed
        mock_objects.filter.assert_called_once_with(id=mock_data["id"])
        mock_objects.filter.return_value.exists.assert_called_once_with()
        mock_atomic.return_value.__enter__.assert_called_once_with()
        mock__create_from_stripe_object.assert_called_once_with(
            mock_data, api_key=djstripe_settings.STRIPE_SECRET_KEY
        )
        (
            mock__create_from_stripe_object.return_value.invoke_webhook_handlers
        ).assert_called_once_with()
        # Make sure the event was returned.
        self.assertEqual(mock__create_from_stripe_object.return_value, result)
Test that process event creates a new event and invokes webhooks
        when the event doesn't already exist.
        
tests/test_event.py