Files
zkxw/backend/tests/test_sample_payment_list_helpers.py
T
zlwuandCursor c35e4ca3d2 feat(backend): add sample-payments list and detail read APIs
Support per-sample payment overview for the standalone payment-info menu.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-05 12:57:55 +08:00

38 lines
1.3 KiB
Python

"""样本缴费列表:进度过滤与分页顺序"""
import unittest
from app.crud.protocol_sample_payment import _filter_and_page_progress
class TestFilterAndPageProgress(unittest.TestCase):
def test_filter_bfyj_before_paging(self):
rows = [
{"id": "1", "progressStatus": "dfj"},
{"id": "2", "progressStatus": "bfyj"},
{"id": "3", "progressStatus": "bfyj"},
{"id": "4", "progressStatus": "yjq"},
{"id": "5", "progressStatus": "bfyj"},
]
page1, total = _filter_and_page_progress(rows, "bfyj", 1, 2)
self.assertEqual(total, 3)
self.assertEqual(len(page1), 2)
self.assertEqual(page1[0]["id"], "2")
self.assertEqual(page1[1]["id"], "3")
page2, total2 = _filter_and_page_progress(rows, "bfyj", 2, 2)
self.assertEqual(total2, 3)
self.assertEqual(len(page2), 1)
self.assertEqual(page2[0]["id"], "5")
def test_no_progress_filter_returns_all_paged(self):
rows = [{"id": str(i), "progressStatus": "dfj"} for i in range(5)]
page, total = _filter_and_page_progress(rows, None, 1, 3)
self.assertEqual(total, 5)
self.assertEqual(len(page), 3)
self.assertEqual([r["id"] for r in page], ["0", "1", "2"])
if __name__ == "__main__":
unittest.main()