Before a new version goes live, a release checklist makes sure nothing was forgotten on the server. Your function release_checklist(env, db, client) gets the server's environment variables as a dictionary, its database, and a test client of its app. It collects what is wrong in a list, problems, and the code at the end prints it.
Each check reads a value, compares it, and appends a sentence when something is wrong. Here is a check for another setting:
env = {"SHOP_NAME": "Mug Shop", "ADMIN_EMAIL": ""}
problems = []
if env.get("ADMIN_EMAIL", "") == "":
problems.append("set ADMIN_EMAIL")
print(problems) # ['set ADMIN_EMAIL']
Your checklist asks four things, in this order. Debug mode is off: FLASK_DEBUG is "0", or not set at all. Every name in SECRETS is set and not empty. Every name in MIGRATIONS has its row in the table migrations: fetchone() gives None when it doesn't. And GET /health answers 200.
Six test servers go through the checklist. The finished code prints:
Server 1: all set Ready to release Server 2: debug left on To do: turn debug off (FLASK_DEBUG is 1) Server 3: secrets forgotten To do: set the secret SECRET_KEY To do: set the secret WEBHOOK_SECRET Server 4: new code, old database To do: run the migration 003_add_reviews Server 5: the app is not healthy To do: fix /health, it answers 503 Server 6: nothing done yet To do: turn debug off (FLASK_DEBUG is true) To do: set the secret SECRET_KEY To do: set the secret PAYMENTS_API_KEY To do: set the secret WEBHOOK_SECRET To do: run the migration 001_create_products To do: run the migration 002_create_orders To do: run the migration 003_add_reviews To do: fix /health, it answers 503
Your task: inside release_checklist, add the four checks: debug, then the secrets, then the migrations, then /health. Each one appends the sentence that follows To do: in the output above.
Assignment
Follow the Coding Tutorial to add the four checks of the release checklist: debug off, secrets set, migrations run and /health green.
Hintenv.get with a default never raises. Look up each migration with a ? placeholder and the tuple (name,). Turn the status code into text with str before adding it to a sentence.
Free plan: 30 tutor messages. PRO is unlimited.
