From f8d1497bb07f7de59ed57b5cbbb6376a0a17016c Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Fri, 20 Dec 2024 17:02:11 +0100 Subject: [PATCH] docs: split tests needed for the new event --- docs/how-tos/create-a-new-event.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/how-tos/create-a-new-event.rst b/docs/how-tos/create-a-new-event.rst index b931d0c0..1fa96f0c 100644 --- a/docs/how-tos/create-a-new-event.rst +++ b/docs/how-tos/create-a-new-event.rst @@ -233,7 +233,11 @@ Step 7: Test the Event You should test the event to ensure it triggers consistently and that its payload contains the necessary information. Add unit tests in the service that triggers the event. The main goal is to verify that the event triggers as needed, consumers can react to it, and it carries the expected information. -In our example, we should add checks for all places where the event is triggered to ensure that the event is triggered consistently. We should also verify that the payload contains the necessary information for consumers to react to the event like user information, course information, enrollment mode, and other relevant data. +To ensure that our example is tested thoroughly, we should: + +- Add unit tests to the ``enroll`` method to ensure that the event is triggered when a user enrolls in a course. This means testing the event is triggered when the enrollment process completes successfully. +- Add checks to ensure that the event is triggered consistently and only when the event should be triggered. +- Verify that the payload contains the necessary information for consumers to react to the event like user information, course information, enrollment mode, and other relevant data. Another way we suggest you test your events is by consuming them in a test environment. This will help you verify that the event is triggered and that the payload contains the necessary information. You can use follow the steps in :doc:`../how-tos/consume-an-event` to consume the event in a test environment with a Django Signal Receiver. Or you could also use the Open edX Event Bus to consume the event in a test environment. For more information on how to use the Open edX Event Bus, refer to the :doc:`../how-tos/use-the-event-bus-to-broadcast-and-consume-events`.