def test_should_set_prev_page(): assert search_helpers.pagination(99, 100)["prev_page"] is None assert search_helpers.pagination(101, 100, 2)["prev_page"] == 1 assert search_helpers.pagination(301, 100, 3)["prev_page"] == 2 assert search_helpers.pagination(301, 100, 100)["prev_page"] == 4
def test_should_hide_both_next_and_prev_if_no_services(): assert not search_helpers.pagination(0, 100)["show_prev"] assert not search_helpers.pagination(0, 100)["show_next"]
def test_set_total_pages(): assert search_helpers.pagination(99, 100)["total_pages"] == 1 assert search_helpers.pagination(100, 100)["total_pages"] == 1 assert search_helpers.pagination(101, 100)["total_pages"] == 2
def test_should_set_next_page(): assert search_helpers.pagination(99, 100)["next_page"] is None assert search_helpers.pagination(101, 100)["next_page"] == 2 assert search_helpers.pagination(201, 100, 2)["next_page"] == 3
def test_hide_next_if_last_page(): assert not search_helpers.pagination(101, 100, 2)["show_next"]
def test_show_prev_as_last_page_if_too_big_page(): assert search_helpers.pagination(101, 100, 20)["show_prev"]
def test_show_next(): assert search_helpers.pagination( 101, 100, )["show_next"] assert search_helpers.pagination(101, 100, 1)["show_next"]
def test_should_show_prev_if_last_page(): assert search_helpers.pagination(201, 100, 2)["show_prev"]
def test_should_show_prev_if_after_page_one(): assert search_helpers.pagination(101, 100, 2)["show_prev"]
def test_should_hide_prev_if_page_one(): assert not search_helpers.pagination(101, 100)["show_prev"]
def test_should_hide_both_next_and_prev_if_less_services_than_page(): assert not search_helpers.pagination(50, 100)["show_prev"] assert not search_helpers.pagination(50, 100)["show_next"]