This is a quick presentation showing a few different ways in which we can test a Django application. It is by no means a comprehensive look at testing (as if you could do such a thing) but is more intended to serve 2 purposes:
- show you some examples of how to get started
- convince you that you should just get testing, whatever that looks like
the test case
The scenario under test is simple:
> when a user submits their email in the form < then the email is saved
You can find 3 different testing examples in the different branches of this repo:
a(this branch) has The Django Way™ of testing, using
unittest.mock.patchto test the same view
cpulls the business logic out of the view (ala Uncle Bob) and uses
unittest.mock.patchto mock out the database layer
The areas of interest in this repo will primarily be
hackers.tests. If you toggle branches viewing those files you will see
the primary differences in the test approaches.
You can find the slides for my talk by clicking here.