mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 23:07:03 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JThjboXTeZ3yJPBzxMx5wS
32 lines
973 B
Python
32 lines
973 B
Python
from __future__ import annotations
|
|
|
|
from python_pkg.token_dashboard import active
|
|
|
|
|
|
def test_gap_over_limit_contributes_zero_not_the_limit() -> None:
|
|
spans = active.intervals([0, 60, 120, 1000, 1030])
|
|
assert spans == [(0, 120), (1000, 1030)]
|
|
assert active.measure(spans) == 150
|
|
|
|
|
|
def test_union_bridges_short_gaps_between_files() -> None:
|
|
main = [(0.0, 100.0)]
|
|
sub = [(250.0, 400.0)] # 150 s after main went quiet: still active
|
|
far = [(2000.0, 2010.0)]
|
|
assert active.measure(main + sub + far) == 410
|
|
|
|
|
|
def test_overlapping_intervals_count_once() -> None:
|
|
assert active.measure([(0.0, 100.0), (50.0, 150.0)]) == 150
|
|
|
|
|
|
def test_clip_to_a_prompt_window() -> None:
|
|
spans = [(0.0, 100.0), (1000.0, 1100.0)]
|
|
assert active.measure(spans, 50.0, 1050.0) == 100
|
|
assert active.measure([], 0.0, 10.0) == 0
|
|
|
|
|
|
def test_empty_and_single_stamp() -> None:
|
|
assert active.intervals([]) == []
|
|
assert active.intervals([5.0]) == [(5.0, 5.0)]
|