Check real interfaces and failure paths against the original requirement.
Section 3.1 1 of 7
Overview
Focus
Check real interfaces and failure paths against the original requirement.
Your route through the lesson
3.2 Conflicting schemas, units, and assumptions
3.3 Contract tests and integration checks
3.4 Final acceptance and unresolved claims
3.5 Put it into practice
3.6 Guided comparison
3.7 An interface using the wrong time unit
All required teaching is included here. Review selections are saved. Choose a correct answer for every question to continue; retries are unlimited. Study time and personal notes are optional.
Section 3.2 2 of 7
Conflicting schemas, units, and assumptions
Focus
Make schemas, units, and assumptions explicit at every interface.
Two components can pass their own tests and still fail together because they interpret exchanged values differently. A schema describes fields and types; units describe meaning; assumptions describe conditions under which the values are valid. A number without a unit is often an incomplete contract.
Consider a producer emitting timestamp=120000 in milliseconds while a consumer treats it as seconds. Both accept integers, so a type check passes. Yet an expiry calculated by adding sixty seconds is dramatically wrong. A complete interface carries unit='milliseconds' or uses an unambiguous field such as timestamp_ms. The consumer must reject unsupported units or use an explicit tested adapter.
Other mismatches include local time versus coordinated universal time, cents versus dollars, inclusive versus exclusive interval ends, and null versus missing fields. Spell out those conventions in the contract. Do not infer units solely from whether a value looks large: future dates and small test values can defeat that heuristic. Integration begins by comparing meanings across the boundary, not merely matching field names and data types.
// Quick review
Check your understanding.
Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.
Section 3.3 3 of 7
Contract tests and integration checks
Focus
Test contracts and complete paths through real component boundaries.
A contract test checks that a producer's output satisfies a consumer's declared interface. An integration check connects the actual components and observes the complete path. These overlap but answer different questions. A handcrafted consumer fixture may satisfy a schema while the real producer emits another unit; connecting them exposes that gap.
For the timestamp example, a contract check requires unit seconds before the consumer adds sixty. The raw millisecond record is rejected. A deliberate adapter divides by 1000 and labels the result seconds, so 120000 milliseconds becomes 120 seconds and expiry becomes 180 seconds. The adapter must preserve intended precision and define how fractional values are handled.
Include a supported path and a safe failure path. The failure should reject before a consequential effect rather than compute with guessed units. Record which boundaries are real and which remain simulated. A test double is a controlled substitute for a component; it can prove handling of selected responses but cannot establish the behavior of a service it never contacts. Final integration claims must therefore name actual interfaces and remaining substitutes.
// Quick review
Check your understanding.
Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.
Section 3.4 4 of 7
Final acceptance and unresolved claims
Focus
Accept the integrated result against the original requirement and label unresolved claims.
Final acceptance returns to the user's original requirement rather than merely collecting local pass labels. List the central claims and the evidence for each: correct output, authorized behavior, compatible interfaces, failure handling, and any required recovery. A claim with no corresponding observation remains unresolved.
Suppose the requirement is expire a local reservation sixty seconds after the event. A successful path must show event time converted correctly, expiry stored correctly, and the consumer using that expiry. A negative path must show a record with an unsupported unit is rejected without scheduling an expiry. A producer test plus a consumer test that never connect cannot establish the complete path.
Incomplete specifications also block acceptance. If the requirement omits rounding for fractional milliseconds, document the gap and restrict the accepted scope to exact whole-second fixtures until the rule is resolved. Do not claim general timestamp support. Acceptance can be partial and useful when its limits are explicit. The report should distinguish checked behavior, represented behavior through a substitute, and untested behavior so later users cannot mistake a local demonstration for a deployed end-to-end service.
// Quick review
Check your understanding.
Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.
Section 3.5 5 of 7
Put it into practice
Focus
Run a unit mismatch, explicit conversion, and safe rejection in one integrated fixture.
Download week15.py, save it in an exercise folder, and run python week15.py --lesson 3. The single practice connects a fixed record producer to a consumer function. It uses only the standard library, no network, and a small processor; expected runtime is seconds. No generated program is executed.
The consumer checks record.get('unit') != 'seconds'. Dictionary get returns the stored value or None when the key is missing. The != operator means not equal. If the unit is unsupported, raise ValueError stops normal execution with a specific error. try and except ValueError let the fixture observe that expected rejection without crashing the entire demonstration.
The first record contains timestamp 120000 and unit milliseconds. It must be denied. The converted record divides the timestamp by 1000 and labels seconds. Consumer then adds 60, producing 180. Assertions verify both paths and printed PASS identifies the actual observed behavior. This fixture supplies an explicit unit contract; it does not claim the original business specification is complete for time zones, fractional rounding, or every date representation. Those are separate scope decisions, not hidden assumptions the learner must guess.
Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.
Section 3.6 6 of 7
Guided comparison
Focus
Trace the mismatch and adapter without allowing an error handler to hide defects.
The worked consumer refuses the original record because its unit is milliseconds. This rejection is expected and counted as a successful boundary check, not as successful business processing. The try block catches ValueError and sets denied=True; an assertion then verifies that the rejection occurred. If validation were accidentally removed, denied would remain false and the test would fail.
Next, the adapter changes both value and unit: 120000/1000 becomes 120 seconds. Changing only the label would be wrong because it would reinterpret the same magnitude. The consumer adds sixty to obtain expiry 180. The assertion checks that number directly, preventing a plausible-looking report from substituting for the calculation.
The error handler catches only the intended exception. Catching every exception and printing PASS would hide programming mistakes, missing variables, or file failures. Good failure tests distinguish expected denial from accidental crashes. The same principle applies to team integration: a module returning any error is not automatically a correct safe failure. Its reason, timing, and absence of unintended effects must match the declared contract.
// Quick review
Check your understanding.
Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.
Section 3.7 7 of 7
An interface using the wrong time unit
Focus
Repair a wrong time unit through a documented adapter and a measurable end-to-end result.
A queue producer records delay=5000 in milliseconds, while a scheduler expects delay_seconds. Both components work in their own local tests. Connected directly, the scheduler waits five thousand seconds instead of five. The problem is at the interface, so adding more independent component tests using the same assumptions will not expose the actual connected behavior.
The worked repair defines an adapter accepting only unit milliseconds and converting 5000 to 5 seconds. The adapter emits delay_seconds=5 under a new interface version. An integration check feeds the actual producer record through the adapter to a harmless local scheduler simulator and observes scheduled_delay=5. A negative record with unknown unit is rejected before scheduling.
The final report states the supported unit, conversion, interface version, normal result, and safe failure. It does not claim that waiting five real seconds proves a production queue's delivery guarantees; the fixture checks scheduling parameters, not external delivery. This transfer shows how acceptance should follow the original user-visible requirement while labeling the exact boundary exercised and any operational behavior still outside the test.
// Quick review
Check your understanding.
Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.
Your personal notes
Optional, ungraded, and saved only in this browser. Export a backup from the Academy homepage to keep them.