From 59b11903c5809cfdb02015fe5ef11b5a97c2df82 Mon Sep 17 00:00:00 2001 From: route92 <133750395+route92@users.noreply.github.com> Date: Tue, 16 May 2023 09:55:59 +0200 Subject: [PATCH 01/10] Pudding should now be less messy Fixed "the proof is in the pudding" to "the proof of the pudding". The phrase is: "The proof of the pudding is in the eating." That's how you know it's pudding. If the proof would be in the pudding, it would just be messy. --- part1.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/part1.asciidoc b/part1.asciidoc index a44eecf2..9e066c8c 100644 --- a/part1.asciidoc +++ b/part1.asciidoc @@ -60,7 +60,7 @@ Three appendices are further explorations of the content from Part I: code: how we build and run the Docker images, where we manage configuration info, and how we run different types of tests. -* <> is a "proof is in the pudding" kind of content, showing +* <> is a "proof of the pudding" kind of content, showing how easy it is to swap out our entire infrastructure--the Flask API, the ORM, and Postgres—for a totally different I/O model involving a CLI and CSVs. From f8fcd9bb80bd51c9f1f6c946aa9101077cc67a05 Mon Sep 17 00:00:00 2001 From: birdca Date: Tue, 23 May 2023 20:11:24 +0800 Subject: [PATCH 02/10] fix: grep command --- chapter_05_high_gear_low_gear.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter_05_high_gear_low_gear.asciidoc b/chapter_05_high_gear_low_gear.asciidoc index bfb1366e..265f159c 100644 --- a/chapter_05_high_gear_low_gear.asciidoc +++ b/chapter_05_high_gear_low_gear.asciidoc @@ -48,7 +48,7 @@ does to our test pyramid: [source,sh] [role="skip"] ---- -$ grep -c test_ **/test_*.py +$ grep -c test_ */*/test_*.py tests/unit/test_allocate.py:4 tests/unit/test_batches.py:8 tests/unit/test_services.py:3 From 609d5a2303c632012bee7105a6d83eb03f4b708a Mon Sep 17 00:00:00 2001 From: Harry Date: Mon, 11 Sep 2023 14:11:01 +0100 Subject: [PATCH 03/10] Fix code issue 4, add explanation re nested tuple unpacking --- chapter_06_uow.asciidoc | 14 +++++++++++--- code | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/chapter_06_uow.asciidoc b/chapter_06_uow.asciidoc index 9420e0ad..24c9a2a2 100644 --- a/chapter_06_uow.asciidoc +++ b/chapter_06_uow.asciidoc @@ -169,11 +169,11 @@ def insert_batch(session, ref, sku, qty, eta): def get_allocated_batch_ref(session, orderid, sku): - [[orderlineid]] = session.execute( + [[orderlineid]] = session.execute( #<1> "SELECT id FROM order_lines WHERE orderid=:orderid AND sku=:sku", dict(orderid=orderid, sku=sku), ) - [[batchref]] = session.execute( + [[batchref]] = session.execute( #<1> "SELECT b.reference FROM allocations JOIN batches AS b ON batch_id = b.id" " WHERE orderline_id=:orderlineid", dict(orderlineid=orderlineid), @@ -182,7 +182,15 @@ def get_allocated_batch_ref(session, orderid, sku): ---- ==== -// TODO: that double-unpacking is freaking ppl out. maybe [(orderlineid, )] ? +<1> The `[[orderlineid]] =` syntax is a little too-clever-by-half, apologies. + What's happening is that `session.execute` returns a list of rows, + where each row is a tuple of column values; + in our specific case, it's a list of one row, + which is a tuple with one column value in. + The double-square-bracket on the left hand side + is doing (double) assignment-unpacking to get the single value + back out of these two nested sequences. + It becomes readable once you've used it a few times! === Unit of Work and Its Context Manager diff --git a/code b/code index 3ed6ff0f..734df09a 160000 --- a/code +++ b/code @@ -1 +1 @@ -Subproject commit 3ed6ff0fab52e14edba6ced4b258af68c521115f +Subproject commit 734df09afc65ba43c851271def147c70ac3c3b98 From a0679777ac4372bf6de572f055af0614f8f61fa9 Mon Sep 17 00:00:00 2001 From: Harry Date: Thu, 22 Feb 2024 23:21:14 +0000 Subject: [PATCH 04/10] fix a problem with the isolated-fakemessagebus --- chapter_09_all_messagebus.asciidoc | 7 +++---- preface.asciidoc | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/chapter_09_all_messagebus.asciidoc b/chapter_09_all_messagebus.asciidoc index df129145..0ef9a65d 100644 --- a/chapter_09_all_messagebus.asciidoc +++ b/chapter_09_all_messagebus.asciidoc @@ -845,10 +845,9 @@ class FakeUnitOfWorkWithFakeMessageBus(FakeUnitOfWork): super().__init__() self.events_published = [] # type: List[events.Event] - def publish_events(self): - for product in self.products.seen: - while product.events: - self.events_published.append(product.events.pop(0)) + def collect_new_events(self): + self.events_published += super().collect_new_events() + return [] ---- ==== diff --git a/preface.asciidoc b/preface.asciidoc index 12c91f8a..4369e2d1 100644 --- a/preface.asciidoc +++ b/preface.asciidoc @@ -347,7 +347,7 @@ Ben Judson, James Gregory, Łukasz Lechowicz, Clinton Roy, Vitorino Araújo, Susan Goodbody, Josh Harwood, Daniel Butler, Liu Haibin, Jimmy Davies, Ignacio Vergara Kausel, Gaia Canestrani, Renne Rocha, pedroabi, Ashia Zawaduk, Jostein Leira, Brandon Rhodes, Jazeps Basko, simkimsia, Adrien Brunet, Sergey Nosko, -Dmitry Bychkov, +Dmitry Bychkov, dayres2, programmer-ke and many more; our apologies if we missed you on this list. Super-mega-thanks to our editor Corbin Collins for his gentle chivvying, and From d25c4c2dc006166cf927fbf776ade9eb49e3fc26 Mon Sep 17 00:00:00 2001 From: Harry Date: Thu, 6 Jun 2024 09:50:44 +0100 Subject: [PATCH 05/10] Add asjhita to acks, he helped fix #352 cf https://github.com/cosmicpython/cosmicpython.github.io/commit/af73230b3950023383282070e00e6c68e3b009f6 --- preface.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preface.asciidoc b/preface.asciidoc index 4369e2d1..3c740cd8 100644 --- a/preface.asciidoc +++ b/preface.asciidoc @@ -347,7 +347,7 @@ Ben Judson, James Gregory, Łukasz Lechowicz, Clinton Roy, Vitorino Araújo, Susan Goodbody, Josh Harwood, Daniel Butler, Liu Haibin, Jimmy Davies, Ignacio Vergara Kausel, Gaia Canestrani, Renne Rocha, pedroabi, Ashia Zawaduk, Jostein Leira, Brandon Rhodes, Jazeps Basko, simkimsia, Adrien Brunet, Sergey Nosko, -Dmitry Bychkov, dayres2, programmer-ke +Dmitry Bychkov, dayres2, programmer-ke, asjhita, and many more; our apologies if we missed you on this list. Super-mega-thanks to our editor Corbin Collins for his gentle chivvying, and From ff1fe7aedd734fcda1a7b88d25907c1288269cb4 Mon Sep 17 00:00:00 2001 From: Dmytro Chebruchan <47272162+DmytroChebruchan@users.noreply.github.com> Date: Wed, 12 Jun 2024 16:56:57 +0300 Subject: [PATCH 06/10] Update part1.asciidoc Change of link to Service Layer pattern. Link should be for words "Service Layer pattern" as with other patterns and not only for words "Service Layer". --- part1.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/part1.asciidoc b/part1.asciidoc index 9e066c8c..2d357b7d 100644 --- a/part1.asciidoc +++ b/part1.asciidoc @@ -32,7 +32,7 @@ To do that, we present four key design patterns: * The <>, an abstraction over the idea of persistent storage -* The <> pattern to clearly define where our +* The <> to clearly define where our use cases begin and end [role="pagebreak-before"] From 5574eb4bd3118978f2f6a86cd2f9022520685a78 Mon Sep 17 00:00:00 2001 From: Harry Date: Wed, 5 Feb 2025 13:06:17 +0000 Subject: [PATCH 07/10] fix link to nat freeman mocking talk --- chapter_03_abstractions.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter_03_abstractions.asciidoc b/chapter_03_abstractions.asciidoc index b85981fb..8f7af2a8 100644 --- a/chapter_03_abstractions.asciidoc +++ b/chapter_03_abstractions.asciidoc @@ -784,7 +784,7 @@ story we care about. ((("PyCon talk on Mocking Pitfalls"))) ((("Jung, Ed"))) Steve Freeman has a great example of overmocked tests in his talk -https://oreil.ly/jAmtr["Test-Driven Development"]. +https://youtu.be/yuEbZYKgZas?si=ZpBoivlDH13XTG9p&t=294["Test-Driven Development: That's Not What We Meant"]. You should also check out this PyCon talk, https://oreil.ly/s3e05["Mocking and Patching Pitfalls"], by our esteemed tech reviewer, Ed Jung, which also addresses mocking and its alternatives. From 140f177023db7d171bf510be8664fcdf5d0d1eff Mon Sep 17 00:00:00 2001 From: Filip Lajszczak Date: Sat, 15 Feb 2025 07:16:53 +0000 Subject: [PATCH 08/10] Makes presentation of alternative constructor of FakeRepository consistent with the current shape of it in Chapter 2. --- chapter_05_high_gear_low_gear.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter_05_high_gear_low_gear.asciidoc b/chapter_05_high_gear_low_gear.asciidoc index 265f159c..a6d8550d 100644 --- a/chapter_05_high_gear_low_gear.asciidoc +++ b/chapter_05_high_gear_low_gear.asciidoc @@ -310,7 +310,7 @@ function on `FakeRepository`: [source,python] [role="skip"] ---- -class FakeRepository(set): +class FakeRepository(repository.AbstractRepository): @staticmethod def for_batch(ref, sku, qty, eta=None): From 7e10e79c1db961ea071daf57c4aed3089d9b7ed2 Mon Sep 17 00:00:00 2001 From: Harry Date: Mon, 12 May 2025 12:03:27 +0100 Subject: [PATCH 09/10] extra ack for filip --- preface.asciidoc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/preface.asciidoc b/preface.asciidoc index 3c740cd8..d8b98e78 100644 --- a/preface.asciidoc +++ b/preface.asciidoc @@ -347,7 +347,7 @@ Ben Judson, James Gregory, Łukasz Lechowicz, Clinton Roy, Vitorino Araújo, Susan Goodbody, Josh Harwood, Daniel Butler, Liu Haibin, Jimmy Davies, Ignacio Vergara Kausel, Gaia Canestrani, Renne Rocha, pedroabi, Ashia Zawaduk, Jostein Leira, Brandon Rhodes, Jazeps Basko, simkimsia, Adrien Brunet, Sergey Nosko, -Dmitry Bychkov, dayres2, programmer-ke, asjhita, +Dmitry Bychkov, dayres2, programmer-ke, asjhita, Filip Lajszczak, and many more; our apologies if we missed you on this list. Super-mega-thanks to our editor Corbin Collins for his gentle chivvying, and @@ -356,6 +356,4 @@ the production staff, Katherine Tozer, Sharon Wilkey, Ellen Troutman-Zaig, and Rebecca Demarest, for your dedication, professionalism, and attention to detail. This book is immeasurably improved thanks to you. -// TODO thanks to rest of OR team. - Any errors remaining in the book are our own, naturally. From 14c204a609f50ef3a38c0bff87b1db6c7d14cbc9 Mon Sep 17 00:00:00 2001 From: Tom Nguyen <7121553+tunggnu@users.noreply.github.com> Date: Thu, 17 Jul 2025 14:24:59 +0700 Subject: [PATCH 10/10] Fix a minor syntax error in asciidoctor-clean.custom.css Although all browsers will render the generated HTML files correctly even if they are missing a curly bracket, it's better to fix this error. --- theme/asciidoctor-clean.custom.css | 1 + 1 file changed, 1 insertion(+) diff --git a/theme/asciidoctor-clean.custom.css b/theme/asciidoctor-clean.custom.css index 00a945c5..ac11c462 100644 --- a/theme/asciidoctor-clean.custom.css +++ b/theme/asciidoctor-clean.custom.css @@ -89,3 +89,4 @@ table { width: 55vw!important; font-size: 3vw; } +}