Every shipment since a date, all pages (needs from the docs: D4 paging)
cd /app; cat shop/shipping.py; grep -n -i tern shop/settings.py; ls . tests 2>/dev/null; curl -s localhost:8080/
"""Shipping with Tern, our carrier. Use shop.tern.call for requests; shop.settings has the warehouse postcode."""
from datetime import date
from shop.cart import Cart
from shop.orders import Order
def quote_at_checkout(cart: Cart, postcode: str) -> int:
"""The cheapest price Tern offers to ship this cart from the warehouse to postcode, in pence."""
raise NotImplementedError
def quote_options(cart: Cart, postcode: str) -> list[tuple[str, int, int]]:
"""Every service Tern offers for this cart and postcode, as (service, price in pence, days to deliver),
cheapest first."""
raise NotImplementedError
def book(order: Order, service: str) -> str:
"""Book the order's parcel with Tern on the given service and return Tern's shipment id."""
raise NotImplementedError
def shipments_since(day: date) -> list[dict]:
"""Every Tern shipment created on or after day, as Tern describes them."""
raise NotImplementedError
def order_status(shipment_id: str) -> str:
"""The shop's status (one of shop.orders.STATUSES) for the order whose Tern shipment this is."""
raise NotImplementedError
def cancel(order: Order) -> bool:
"""Cancel the order's Tern shipment. True if Tern cancelled it; False if it is too late to cancel."""
raise NotImplementedError
3:TERN_API_URL = os.environ.get("TERN_API_URL", "http://localhost:8081")
4:TERN_API_KEY = os.environ.get("TERN_API_KEY", "tern_test_larkspur")
.:
README.md
pytest.ini
shop
tests
tests:
__init__.py
test_cart.py
test_orders.py
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
[stdout]
"""Shipping with Tern, our carrier. Use shop.tern.call for requests; shop.settings has the warehouse postcode."""
from datetime import date
from shop.cart import Cart
from shop.orders import Order
def quote_at_checkout(cart: Cart, postcode: str) -> int:
"""The cheapest price Tern offers to ship this cart from the warehouse to postcode, in pence."""
raise NotImplementedError
def quote_options(cart: Cart, postcode: str) -> list[tuple[str, int, int]]:
"""Every service Tern offers for this cart and postcode, as (service, price in pence, days to deliver),
cheapest first."""
raise NotImplementedError
def book(order: Order, service: str) -> str:
"""Book the order's parcel with Tern on the given service and return Tern's shipment id."""
raise NotImplementedError
def shipments_since(day: date) -> list[dict]:
"""Every Tern shipment created on or after day, as Tern describes them."""
raise NotImplementedError
def order_status(shipment_id: str) -> str:
"""The shop's status (one of shop.orders.STATUSES) for the order whose Tern shipment this is."""
raise NotImplementedError
def cancel(order: Order) -> bool:
"""Cancel the order's Tern shipment. True if Tern cancelled it; False if it is too late to cancel."""
raise NotImplementedError
3:TERN_API_URL = os.environ.get("TERN_API_URL", "http://localhost:8081")
4:TERN_API_KEY = os.environ.get("TERN_API_KEY", "tern_test_larkspur")
.:
README.md
pytest.ini
shop
tests
tests:
__init__.py
test_cart.py
test_orders.py
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
[metadata] {"noOutputExpected": false}cd /app; cat shop/tern.py; cat README.md | head -30; curl -s localhost:8080/docs; curl -s localhost:8080/index.html | head -50
"""A thin client for Tern's API: the key, JSON in and out. Which paths and fields to use is up to the caller."""
import json
import urllib.error
import urllib.parse
import urllib.request
from shop import settings
def call(method: str, path: str, body: dict | None = None, params: dict | None = None,
headers: dict | None = None, timeout: float = 10) -> tuple[int, dict]:
"""One request to Tern. Returns (HTTP status, decoded JSON body); an error status is returned, not raised.
A connection that fails or drops raises, as urllib does."""
url = settings.TERN_API_URL.rstrip("/") + path
if params:
url += "?" + urllib.parse.urlencode(params)
data = json.dumps(body).encode() if body is not None else None
request = urllib.request.Request(url, data=data, method=method)
request.add_header("Authorization", f"Bearer {settings.TERN_API_KEY}")
request.add_header("Accept", "application/json")
if data is not None:
request.add_header("Content-Type", "application/json")
for name, value in (headers or {}).items():
request.add_header(name, value)
try:
with urllib.request.urlopen(request, timeout=timeout) as response:
return response.status, json.loads(response.read() or b"{}")
except urllib.error.HTTPError as e:
raw = e.read()
return e.code, json.loads(raw) if raw else {}
# Larkspur Tea: shop backend
The order and checkout logic behind Larkspur Tea's online shop. Plain Python 3.13, no framework, no dependencies
beyond pytest for the tests.
- `shop/cart.py`: carts and items. Prices are in pence; weights are in kilograms, as the warehouse weighs them.
- `shop/orders.py`: orders and the order statuses the shop shows customers.
- `shop/shipping.py`: everything to do with our carrier, Tern. Mostly still to write.
- `shop/tern.py`: a thin client for Tern's API (authentication, JSON in and out).
- `shop/settings.py`: configuration, from the environment with defaults for development.
## Shipping
We ship everything with Tern. In development, `TERN_API_URL` points at Tern's sandbox and `TERN_API_KEY` holds a
test key; both default to what the sandbox expects.
## Tests
```
python -m pytest
```
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
[stdout]
"""A thin client for Tern's API: the key, JSON in and out. Which paths and fields to use is up to the caller."""
import json
import urllib.error
import urllib.parse
import urllib.request
from shop import settings
def call(method: str, path: str, body: dict | None = None, params: dict | None = None,
headers: dict | None = None, timeout: float = 10) -> tuple[int, dict]:
"""One request to Tern. Returns (HTTP status, decoded JSON body); an error status is returned, not raised.
A connection that fails or drops raises, as urllib does."""
url = settings.TERN_API_URL.rstrip("/") + path
if params:
url += "?" + urllib.parse.urlencode(params)
data = json.dumps(body).encode() if body is not None else None
request = urllib.request.Request(url, data=data, method=method)
request.add_header("Authorization", f"Bearer {settings.TERN_API_KEY}")
request.add_header("Accept", "application/json")
if data is not None:
request.add_header("Content-Type", "application/json")
for name, value in (headers or {}).items():
request.add_header(name, value)
try:
with urllib.request.urlopen(request, timeout=timeout) as response:
return response.status, json.loads(response.read() or b"{}")
except urllib.error.HTTPError as e:
raw = e.read()
return e.code, json.loads(raw) if raw else {}
# Larkspur Tea: shop backend
The order and checkout logic behind Larkspur Tea's online shop. Plain Python 3.13, no framework, no dependencies
beyond pytest for the tests.
- `shop/cart.py`: carts and items. Prices are in pence; weights are in kilograms, as the warehouse weighs them.
- `shop/orders.py`: orders and the order statuses the shop shows customers.
- `shop/shipping.py`: everything to do with our carrier, Tern. Mostly still to write.
- `shop/tern.py`: a thin client for Tern's API (authentication, JSON in and out).
- `shop/settings.py`: configuration, from the environment with defaults for development.
## Shipping
We ship everything with Tern. In development, `TERN_API_URL` points at Tern's sandbox and `TERN_API_KEY` holds a
test key; both default to what the sandbox expects.
## Tests
```
python -m pytest
```
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
[metadata] {"noOutputExpected": false}cd /app; for p in /index.html /docs/ /api /openapi.json /llms.txt /shipments /v1 /reference; do echo "== $p"; curl -s -i localhost:8080$p | head -15; done
== /index.html
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /docs/
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /api
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /openapi.json
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /llms.txt
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /shipments
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /v1
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /reference
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
[stdout]
== /index.html
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /docs/
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /api
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /openapi.json
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /llms.txt
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /shipments
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /v1
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
== /reference
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
[metadata] {"noOutputExpected": false}cd /app; curl -s -i -H "Authorization: Bearer tern_test_larkspur" localhost:8081/ | head -20
HTTP/1.1 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: application/json
Content-Length: 22
{"error": "not_found"}
[stdout]
HTTP/1.1 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:36 GMT
Content-Type: application/json
Content-Length: 22
{"error": "not_found"}
[metadata] {"noOutputExpected": false}cd /app; curl -s -i localhost:8080 | head -5; curl -s localhost:8080/robots.txt localhost:8080/sitemap.xml; curl -s -X OPTIONS -i localhost:8080/ | head; grep -rn "8080" / --include=*.md --include=*.py --include=*.txt --include=*.json -l 2>/dev/null | grep -v proc | head
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:38 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
HTTP/1.0 501 Unsupported method ('OPTIONS')
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:38 GMT
Connection: close
Content-Type: text/html;charset=utf-8
Content-Length: 360
<!DOCTYPE HTML>
<html lang="en">
<head>
/usr/share/doc/git/RelNotes/2.21.0.txt
/usr/share/perl/5.40.1/Unicode/Collate/allkeys.txt
/usr/local/lib/python3.13/site-packages/pip/_vendor/idna/idnadata.py
/usr/local/lib/python3.13/site-packages/pip/_vendor/rich/logging.py
/usr/local/lib/python3.13/site-packages/pip/_vendor/urllib3/exceptions.py
/usr/local/lib/python3.13/site-packages/pygments/styles/zenburn.py
/usr/local/lib/python3.13/site-packages/pygments/styles/borland.py
/usr/local/lib/python3.13/site-packages/pygments/styles/trac.py
/usr/lib/python3/dist-packages/mercurial/keepalive.py
/logs/agent/claude-code.txt
[stdout]
HTTP/1.0 404 Not Found
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:38 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 72
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
<!doctype html><title>Not found</title><h1>404</h1><p>No such page.</p>
HTTP/1.0 501 Unsupported method ('OPTIONS')
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:38 GMT
Connection: close
Content-Type: text/html;charset=utf-8
Content-Length: 360
<!DOCTYPE HTML>
<html lang="en">
<head>
/usr/share/doc/git/RelNotes/2.21.0.txt
/usr/share/perl/5.40.1/Unicode/Collate/allkeys.txt
/usr/local/lib/python3.13/site-packages/pip/_vendor/idna/idnadata.py
/usr/local/lib/python3.13/site-packages/pip/_vendor/rich/logging.py
/usr/local/lib/python3.13/site-packages/pip/_vendor/urllib3/exceptions.py
/usr/local/lib/python3.13/site-packages/pygments/styles/zenburn.py
/usr/local/lib/python3.13/site-packages/pygments/styles/borland.py
/usr/local/lib/python3.13/site-packages/pygments/styles/trac.py
/usr/lib/python3/dist-packages/mercurial/keepalive.py
/logs/agent/claude-code.txt
[metadata] {"noOutputExpected": false}cd /app; for p in /docs /docs/index.html /docs/shipments /docs/list-shipments /docs/api /docs/quickstart /docs/pagination /api-docs /guide /v1/docs /docs/errors /docs/authentication; do printf "%s " $p; curl -s -o /dev/null -w "%{http_code}\n" localhost:8080$p; done; for p in /shipments /v1/shipments /v2/shipments; do printf "%s " $p; curl -s -H "Authorization: Bearer tern_test_larkspur" localhost:8081$p | head -c 300; echo; done/docs 404
/docs/index.html 404
/docs/shipments 404
/docs/list-shipments 404
/docs/api 404
/docs/quickstart 404
/docs/pagination 404
/api-docs 404
/guide 404
/v1/docs 404
/docs/errors 404
/docs/authentication 404
/shipments {"error": "not_found"}
/v1/shipments {"error": "not_found"}
/v2/shipments {"shipments": [{"id": "shp_1000", "reference": "LT-5000", "service": "economy", "status": "booked", "created_at": "2026-10-15"}, {"id": "shp_1001", "reference": "LT-5001", "service": "standard", "status": "collected", "created_at": "2026-10-15"}, {"id": "shp_1002", "reference": "LT-5002", "service":
[stdout]
/docs 404
/docs/index.html 404
/docs/shipments 404
/docs/list-shipments 404
/docs/api 404
/docs/quickstart 404
/docs/pagination 404
/api-docs 404
/guide 404
/v1/docs 404
/docs/errors 404
/docs/authentication 404
/shipments {"error": "not_found"}
/v1/shipments {"error": "not_found"}
/v2/shipments {"shipments": [{"id": "shp_1000", "reference": "LT-5000", "service": "economy", "status": "booked", "created_at": "2026-10-15"}, {"id": "shp_1001", "reference": "LT-5001", "service": "standard", "status": "collected", "created_at": "2026-10-15"}, {"id": "shp_1002", "reference": "LT-5002", "service":
[metadata] {"noOutputExpected": false}cd /app; curl -s -i -H "Authorization: Bearer tern_test_larkspur" "localhost:8081/v2/shipments" | python3 -c "
import sys,json
t=sys.stdin.read();h,b=t.split('\r\n\r\n',1);print(h);d=json.loads(b);print({k:(v if k!='shipments' else len(v)) for k,v in d.items()});print(d['shipments'][-1])"HTTP/1.1 200 OK
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:42 GMT
Content-Type: application/json
Content-Length: 2358
{'shipments': 20, 'next_cursor': 'MjA='}
{'id': 'shp_1019', 'reference': 'LT-5019', 'service': 'standard', 'status': 'collected', 'created_at': '2026-10-25'}
[stdout]
HTTP/1.1 200 OK
Server: BaseHTTP/0.6 Python/3.13.18
Date: Sat, 28 Nov 2026 21:19:42 GMT
Content-Type: application/json
Content-Length: 2358
{'shipments': 20, 'next_cursor': 'MjA='}
{'id': 'shp_1019', 'reference': 'LT-5019', 'service': 'standard', 'status': 'collected', 'created_at': '2026-10-25'}
[metadata] {"noOutputExpected": false}cd /app; H="Authorization: Bearer tern_test_larkspur"; for q in "created_since=2026-10-20" "since=2026-10-20" "created_after=2026-10-20" "created_from=2026-10-20" "limit=100" "page_size=100" "per_page=100"; do printf "%s -> " "$q"; curl -s -H "$H" "localhost:8081/v2/shipments?$q" | python3 -c "
import sys,json;d=json.load(sys.stdin);s=d.get('shipments');print(len(s) if s else d, s[0]['created_at'] if s else '', d.get('next_cursor'))"; done
python3 - <<'E'
import sys; sys.path.insert(0,'/app')
from shop import tern
c=None;n=0;ids=[]
while True:
s,b=tern.call("GET","/v2/shipments",params={"cursor":c} if c else None)
ids+= [(x['id'],x['created_at']) for x in b['shipments']]
c=b.get('next_cursor')
if not c:break
print(len(ids),ids[0],ids[-1], ids==sorted(ids,key=lambda x:x[1]))
print(b.keys())
Ecreated_since=2026-10-20 -> 20 2026-10-20 MjA=
since=2026-10-20 -> {'error': 'bad_request', 'message': 'unknown parameter: since'} None
created_after=2026-10-20 -> {'error': 'bad_request', 'message': 'unknown parameter: created_after'} None
created_from=2026-10-20 -> {'error': 'bad_request', 'message': 'unknown parameter: created_from'} None
limit=100 -> {'error': 'bad_request', 'message': 'unknown parameter: limit'} None
page_size=100 -> {'error': 'bad_request', 'message': 'unknown parameter: page_size'} None
per_page=100 -> {'error': 'bad_request', 'message': 'unknown parameter: per_page'} None
47 ('shp_1000', '2026-10-15') ('shp_1046', '2026-11-08') True
dict_keys(['shipments', 'next_cursor'])
[stdout]
created_since=2026-10-20 -> 20 2026-10-20 MjA=
since=2026-10-20 -> {'error': 'bad_request', 'message': 'unknown parameter: since'} None
created_after=2026-10-20 -> {'error': 'bad_request', 'message': 'unknown parameter: created_after'} None
created_from=2026-10-20 -> {'error': 'bad_request', 'message': 'unknown parameter: created_from'} None
limit=100 -> {'error': 'bad_request', 'message': 'unknown parameter: limit'} None
page_size=100 -> {'error': 'bad_request', 'message': 'unknown parameter: page_size'} None
per_page=100 -> {'error': 'bad_request', 'message': 'unknown parameter: per_page'} None
47 ('shp_1000', '2026-10-15') ('shp_1046', '2026-11-08') True
dict_keys(['shipments', 'next_cursor'])
[metadata] {"noOutputExpected": false}cd /app; python3 - <<'E'
import sys; sys.path.insert(0,'/app')
from shop import tern
def allp(p):
c=None;out=[]
while True:
q=dict(p);
if c:q['cursor']=c
s,b=tern.call("GET","/v2/shipments",params=q)
out+=b['shipments'];c=b.get('next_cursor')
if not c:return out
a=allp({});f=allp({"created_since":"2026-10-20"})
exp=[x for x in a if x['created_at']>='2026-10-20']
print(len(a),len(f),len(exp),f==exp, f[0]['created_at'])
E47 37 37 True 2026-10-20
[stdout]
47 37 37 True 2026-10-20
[metadata] {"noOutputExpected": false}cd /app; python3 - <<'E'
p='shop/shipping.py'
s=open(p).read()
s=s.replace(''' """Every Tern shipment created on or after day, as Tern describes them."""
raise NotImplementedError''',''' """Every Tern shipment created on or after day, as Tern describes them."""
shipments = []
cursor = None
while True:
params = {"created_since": day.isoformat()}
if cursor:
params["cursor"] = cursor
status, body = tern.call("GET", "/v2/shipments", params=params)
if status != 200:
raise RuntimeError(f"Tern shipment list failed: {status} {body}")
shipments.extend(body["shipments"])
cursor = body.get("next_cursor")
if not cursor:
return shipments''')
s=s.replace("from shop.orders import Order\n","from shop.orders import Order\nfrom shop import tern\n")
open(p,'w').write(s)
E
cat > tests/test_shipping.py <<'E'
from datetime import date
from shop import shipping, tern
def test_shipments_since_follows_pages(monkeypatch):
pages = {None: ([{"id": "a", "created_at": "2026-10-20"}], "c1"),
"c1": ([{"id": "b", "created_at": "2026-10-21"}], None)}
seen = []
def fake_call(method, path, params=None, **kw):
seen.append(params)
items, nxt = pages[params.get("cursor")]
return 200, {"shipments": items, "next_cursor": nxt}
monkeypatch.setattr(tern, "call", fake_call)
result = shipping.shipments_since(date(2026, 10, 20))
assert [s["id"] for s in result] == ["a", "b"]
assert all(p["created_since"] == "2026-10-20" for p in seen)
E
python -m pytest -q 2>&1 | tail -3
python -c "
from datetime import date;from shop import shipping as s
r=s.shipments_since(date(2026,10,20));print(len(r),r[0])"...... [100%]
6 passed in 0.10s
37 {'id': 'shp_1010', 'reference': 'LT-5010', 'service': 'standard', 'status': 'delivered', 'created_at': '2026-10-20'}
[stdout]
...... [100%]
6 passed in 0.10s
37 {'id': 'shp_1010', 'reference': 'LT-5010', 'service': 'standard', 'status': 'delivered', 'created_at': '2026-10-20'}
[metadata] {"noOutputExpected": false}