A teammate will rewrite the pipeline's latest_per_key transform, and you're writing the test it has to pass. Here is the contract:
latest_per_key(rows) takes a list of dicts, each with a key, an integer version and a value, and returns:
- •one row per key — the row with the highest `version`;
- •if two rows of a key share the highest version, the one later in the input wins;
- •the result is a list of those rows (as dicts with the same contents), sorted by `key`;
- •an empty input gives
[]; - •the input list and its dicts are not modified.
Write check(fn): it calls fn on inputs of your choosing and returns True if fn meets the whole contract on all of them, False otherwise. If fn raises on any input, check returns False — it must never raise itself.
The hidden tests call check on correct implementations (which must pass) and on implementations with one bug each (which must fail).
Python 3.13 in your browser — the standard library plus pandas and numpy; no pip installs.