Hey Bruno,

First of all thank you for the comments on the code snippets — they are all taken care of :)

About the tests, I focused on testing that a signal was sent — I did not test the handler it self. If you want to test the handler you can test is like you would a regular function — no need for fancy context managers.

Django signals are pretty simple. If you look at the implementation the @receiver function add the handler to a list of functions for a certain signal. When the signal is sent Django will iterate the list and execute the handlers one after the other.

In the example above, you can send the signal and right after test that the total_charges for the user got incremented.

Full Stack Developer, Team Leader, Independent. More from me at https://hakibenita.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store