Appendix A. Answers to Exercises

This Appendix contains answers to the exercises presented throughout this book. Keep in mind that there is no single correct solution for any of these exercises. There are many possible solutions, each with their own advantages and disadvantages. Wherever possible, I have mentioned why I took a certain path, so that you can see my reasoning and compare the pros and cons with the solution that you have come up with.

Red-Green-Refactor – The TDD Cycle

This exercise asks us to add support for updates which come out of order, that is, a newer update is followed by an older update. We need to use the timestamp to determine which update is newer and which is older.

The following is a test case for this requirement:

def test_price_is_the_latest_even_if_updates_are_made_out_of_order(self): ...

Get Test-Driven Python Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.