How To Write Unit Tests For Existing Python Code // Part 2 of 2
About
No channel description available.
Latest Posts
Video Description
💡 Learn how to design great software in 7 steps: https://arjan.codes/designguide. This video is part 2 of covering a practical example of adding unit tests to existing code. In the first part, I added tests while not changing the original code. In this part, I show you how refactoring the code makes testing it way easier while improving the design at the same time. I also share a few tips on how to write better unit tests. Part 1 of this series: https://youtu.be/ULxMQ57engo. The code I worked on in this episode is available here: https://github.com/ArjanCodes/2022-test-existing-code. 🎓 ArjanCodes Courses: https://www.arjancodes.com/courses/ 🔖 Chapters: 0:00 Intro 0:44 Recap and analysis 1:58 Add dependency injection to pay_order 3:50 Creating a payment processor mock 6:11 Removing input patching 9:24 Using a fixture for the credit card 11:43 Removing hardcoded dates from the unit tests 12:50 Turning luhn_checksum into a function 14:00 Removing the hardcoded API key from the unit tests 15:44 Final thoughts #arjancodes #softwaredesign #python
Instant Slime Supplies
AI-recommended products based on this video

AQUA CREST UKF8001 Replacement for EveryDrop® Filter 4, Whirlpool® EDR4RXD1, 4396395, Maytag UKF8001P, UKF8001AXX-750, Puriclean II, 46-9006, 6 Month 300 Gallon Refrigerator Water Filter (Pack of 3)

Pink Unicorn Carrying Case Compatible with Nintendo Switch Lite with Crystal Glitter Soft Protective Case Cover+Screen Protector+Stickers, Hard Storage Case Accessories Kit for Girls Birthday Gift

Brita Stainless Steel Premium Filtering Water Bottle, BPA-Free, Reusable, Insulated, Replaces 300 Plastic Water Bottles, Filter Lasts 2 Months or 40 Gallons, Includes 1 Filter, Carbon - 20 oz.




















