Files
company-haness/benchmark/fixtures/GT-01/test_paginate.py
T

23 lines
722 B
Python

"""Objective acceptance test for GT-01 (held as the verify command).
This test currently FAILS against the buggy paginate() (off-by-one drops the last
item). A correct fix makes it pass. The benchmark runner runs `pytest -q` after each
arm and grades first-pass-acceptance on the exit code.
"""
from paginate import paginate
def test_full_page_returns_size_items():
items = list(range(10))
assert paginate(items, 1, 5) == [0, 1, 2, 3, 4]
assert paginate(items, 2, 5) == [5, 6, 7, 8, 9]
def test_last_item_not_dropped():
assert paginate([1, 2, 3], 1, 3) == [1, 2, 3]
def test_partial_last_page():
assert paginate([1, 2, 3, 4, 5], 1, 2) == [1, 2]
assert paginate([1, 2, 3, 4, 5], 3, 2) == [5]