Test Driven Development in the real world: background tasks, time travel, mocking
Vedant Agarwala (~vedant1811) |
Unit testing for a simple application may get complex.
The GET /user API has tests, until it needs to send notifications on API call (i.e. profile view). Orders should allowed to be placed only on specific times but the tests should pass everytime. Need to ensure that the send SMS task calls the correct third party API but doesn't actually send a SMS during test execution.
I will talk about how to address the issues mentioned above and other lessons I have learnt while passionately following TDD. Specifically:
- how to test the business logic of background tasks (trigger, and execution)
- time dependant code (using freezegun)
- patching and asserting calls of external API calls
Basic knowledge of python is enough to understand the talk.
Some experience with writing tests is even better.
(Will add soon)
My self worth is tied to StackOverflow, instead of Instagram (I have 10k+ reputation, so far). I get a dopamine rush when I solve problems.
I'm a Startup enthusiast, Public Speaker, Tech Blogger. One of my startups was acqui-hired.
Currently, the Lead engineer at apna.co