Skip to course content
Free FastAPI backend course

FastAPI for AI Backend Development

Module 07 Knowledge Check

5 questions. Pass mark 4 out of 5. Answer every question before checking the answer key below, then retry after reading the feedback.

1. A dependency differs from a helper function called in the handler because…

2. An expensive object should be…

3. A check that guards but supplies nothing belongs…

4. dependency_overrides lets a test…

5. Business logic in a dependency…

---

Answer Key and Explanations

Check these only after attempting every question.

1. B - it runs before the handler, appears in the docs and cannot be forgotten

The helper is one an author can forget on the endpoint added under time pressure.

2. B - built once behind a cached dependency and injected

A module-level global cannot be replaced in a test.

3. B - in the route decorator's dependencies list

The handler should not take a parameter it never uses.

4. B - run the whole request path with the costly part replaced

That is the payoff for injecting the model rather than importing it.

5. B - becomes reachable only through HTTP

Which is exactly what the service layer exists to prevent.

Practical Check

Apply this module to your own work: complete the module activity for *Dependency Injection for Shared Logic and Settings*, then write one sentence naming what your result shows and one naming what it does not.

Strong Answer Pattern

A strong answer names the task, the evidence used, the check performed, and the remaining limitation. It avoids "proved", "guaranteed", or "always" unless the evidence genuinely supports it.