question 458 Reliable Data Pipelines · hard
Test the checkpoint loader
A teammate wrote load_checkpoint(path) for the nightly job. Its contract: no file → {"offset": 0, "totals": {}}; a valid checkpoint → the saved dictionary; a file that isn't valid JSON, or has an offset that isn't a whole number ≥ 0 → ValueError. Write unittest tests (or test_ functions) that pass for a correct loader and catch broken ones. Your tests create their own files in the current folder. Leave the calls to Check: don't run the tests yourself.
Target
load_checkpoint(path), defined in your file (the starter has a correct version to try your tests on)Your testsa
unittest.TestCase class or test_ functions; each writes the file it needs (use a different name per test)Gradedyour tests must pass for a correct loader and fail for each of three broken loaders