Files
EnuivTools/backend/tests/test_study_poll.py
T

20 lines
641 B
Python

"""与 web/src/shared/studyFields.ts 的 studyPollSeconds 保持一致。"""
def study_poll_seconds(intervals: list[int]) -> int:
if any(value <= 0 for value in intervals):
return 10
positive = [value for value in intervals if value > 0]
if not positive:
return 10
return max(10, min(positive))
def test_study_poll_seconds_floor_and_zero() -> None:
assert study_poll_seconds([]) == 10
assert study_poll_seconds([0]) == 10
assert study_poll_seconds([0, 30]) == 10
assert study_poll_seconds([5]) == 10
assert study_poll_seconds([30]) == 30
assert study_poll_seconds([30, 120]) == 30