Import existing LinTunes project
Snapshot of the existing codebase before working through the TASKS.md backlog. Real library data (data/) and the iTunes import fixture (itunes-test-library/) are gitignored. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
49
tests/test_tap_tempo.py
Normal file
49
tests/test_tap_tempo.py
Normal file
@ -0,0 +1,49 @@
|
||||
from lintunes.tap_tempo import TapTempo
|
||||
|
||||
|
||||
def test_steady_taps_120_bpm():
|
||||
tempo = TapTempo()
|
||||
bpm = None
|
||||
for i in range(5):
|
||||
bpm = tempo.tap(10.0 + i * 0.5) # 0.5s intervals = 120 bpm
|
||||
assert bpm == 120
|
||||
|
||||
|
||||
def test_first_tap_gives_no_bpm():
|
||||
tempo = TapTempo()
|
||||
assert tempo.tap(1.0) is None
|
||||
assert tempo.tap_count == 1
|
||||
|
||||
|
||||
def test_long_gap_resets_series():
|
||||
tempo = TapTempo()
|
||||
tempo.tap(0.0)
|
||||
tempo.tap(0.5)
|
||||
assert tempo.bpm() == 120
|
||||
# 5 seconds later: new series, old taps discarded
|
||||
assert tempo.tap(5.5) is None
|
||||
assert tempo.tap_count == 1
|
||||
assert tempo.tap(6.1) == 100 # 0.6s interval
|
||||
|
||||
|
||||
def test_window_uses_recent_taps_only():
|
||||
tempo = TapTempo()
|
||||
# 4 slow taps (1s = 60bpm) then 8 fast taps (0.25s = 240bpm);
|
||||
# only the last 8 taps count, so the slow ones age out entirely
|
||||
t = 0.0
|
||||
for _ in range(4):
|
||||
tempo.tap(t)
|
||||
t += 1.0
|
||||
for _ in range(8):
|
||||
tempo.tap(t)
|
||||
t += 0.25
|
||||
assert tempo.bpm() == 240
|
||||
|
||||
|
||||
def test_reset():
|
||||
tempo = TapTempo()
|
||||
tempo.tap(0.0)
|
||||
tempo.tap(0.5)
|
||||
tempo.reset()
|
||||
assert tempo.bpm() is None
|
||||
assert tempo.tap_count == 0
|
||||
Reference in New Issue
Block a user