@@ -25,9 +25,9 @@ to at least try out some of the ideas near the end.
2525
2626
2727I'm going to use an example from the domain of logistics where we need to sync
28- to a cargo provider's API, but you can really imagine any old API--a payment
29- gateway, an SMS notifications engine, a cloud storage provider. Or you can
30- imagine an external dependency that's nothing to do with the web at all, just
28+ shipments to a cargo provider's API, but you can really imagine any old API--a
29+ payment gateway, an SMS notifications engine, a cloud storage provider. Or you
30+ can imagine an external dependency that's nothing to do with the web at all, just
3131any kind of external I/O dependency that's hard to unit test.
3232
3333
@@ -59,8 +59,8 @@ class Shipment:
5959
6060
6161We want to sync our shipments model with a third party, the cargo freight
62- company, via their API. We have a couple of use cases, new shipment creation ,
63- and checking for updated etas:
62+ company, via their API. We have a couple of use cases: creating new shipments ,
63+ and checking for updated etas.
6464
6565
6666Let's say we have some sort of controller function that's in charge of doing this. It
@@ -95,7 +95,7 @@ def sync_to_api(shipment):
9595
9696Not too bad!
9797
98- In a case like this, the typical reaction is to reach for mocks,
98+ How do we test it? In a case like this, the typical reaction is to reach for mocks,
9999and _ as long as things stay simple_ , it's pretty manageable
100100
101101
@@ -193,7 +193,7 @@ matter too much, the hope is that this sort of test ugliness is familiar.
193193
194194And this is only the beginning, we've shown an API integration that only cares
195195about writes, but what about reads? Say we want to poll our third party api
196- now and again to get updated etas for ours shipments. Depending on the eta, we
196+ now and again to get updated etas for our shipments. Depending on the eta, we
197197have some business logic about notifying people of delays...
198198
199199
@@ -395,9 +395,8 @@ def test_can_update_a_shipment():
395395That relies on your third- party api having a decent sandbox that you can test against.
396396You' ll need to think about:
397397
398- * how do you clean up? running dozens of tests dozens of times a day in dev
399- and CI will start filling the sandbox with test data. s i can' t, how much
400- data will start piling up in the sandbox
398+ * how do you clean up? Running dozens of tests dozens of times a day in dev
399+ and CI will start filling the sandbox with test data.
401400
402401* is the sandbox slow and annoying to test against? are devs going to be
403402 annoyed at waiting for integration tests to finish on their machines, or
@@ -436,7 +435,7 @@ on the internet I suppose, but still.
436435
437436So when might you think about doing this?
438437
439- * if the integration is not core to your application, ie it' s an incidental feature
438+ * if the integration is not core to your application, i.e it' s an incidental feature
440439* if the bulk of the code you write, and the feedback you want, is not about
441440 integration issues, but about other things in your app
442441* if you really can' t figure out how to fix the problems with your integration
@@ -527,7 +526,7 @@ that mock on _any_ test that might use the third party adapter.
527526
528527> Making the dependency explicit and using DI solves these problems
529528
530- Again, we' re in dangerous territory here. Python people are skeptical
529+ Again, we' re in dangerous territory here. Python people are skeptical
531530of DI , and neither of these problems is _that_ big of a deal. But
532531DI does buy us some nice things, so read on with an open mind.
533532
@@ -590,8 +589,8 @@ def test_create_shipment_syncs_to_api():
590589
591590
592591
593- So far you may think the pros isn ' t enough of a wow to justify the con?
594- Well, if we take it one step further and really commit, you may yet get
592+ So far you may think the pros aren ' t enough of a wow to justify the con?
593+ Well, if we take it one step further and really commit to DI , you may yet get
595594on board.
596595
597596
@@ -637,11 +636,11 @@ def test_create_shipment_syncs_to_api():
637636
638637Why bother with this?
639638
640- # ### handrolled fakes for unit tests, the tradeoffs
639+ # ### Handrolled fakes for unit tests, the tradeoffs
641640
642641# #### Pros:
643642* tests can be more readable, no more `mock.call_args == call(foo,bar)` stuff
644- * 👉Our fake exercises design pressure on our Adapter' s API👈
643+ * 👉Our fake exerts design pressure on our Adapter' s API👈
645644
646645# #### Cons:
647646* more code in tests
0 commit comments