FocusExercise authorized, denied, ineligible, and changed-state cancellation paths locally.
Save week09.py in your exercise folder and run python week09.py --lesson 3. The lab uses a synthetic subscription object with eligible, active, and version fields. It exercises a permitted cancellation, a read-only denial, an ineligible request, and a state change between read and mutation. No account or real subscription is touched.
Python dictionaries can represent the simulator’s state. A copy makes a separate shallow dictionary, sufficient here because the fixture values are simple numbers and booleans. The following complete example shows the version precondition:
subscription = {"eligible": True, "active": True, "version": 4}
observed = subscription.copy()
subscription["version"] = 5
subscription["eligible"] = False
assert observed["version"] != subscription["version"]
assert subscription["active"] is True
The weekly cancel function checks these conditions before changing active. Expected output confirms exactly one permitted effect and zero effects in the three denied paths. The scripted plan demonstrates runtime control and observation handling; it does not demonstrate a model’s planning quality.