Skip to content

Commit 8888e3c

Browse files
Add test for excessively large overflows
1 parent 763e565 commit 8888e3c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/test_rest.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ def test_patch_zones_vol_delta(client):
607607
if z['id'] in range(6):
608608
assert z['vol_f'] - (zones[z['id']]['vol_f'] + 0.1) < 0.0001 and z["vol_f_overflow"] == 0
609609

610-
# test oversized deltas
610+
# test overflowing deltas
611611
rv = client.patch('/api/zones', json={'zones': [z['id'] for z in zones], 'update': {'vol_delta_f': -1.0}})
612612
assert rv.status_code == HTTPStatus.OK
613613
jrv = rv.json()
@@ -618,6 +618,17 @@ def test_patch_zones_vol_delta(client):
618618
assert z['vol_f'] == amplipi.models.MIN_VOL_F
619619
assert z["vol_f_overflow"] == zones[z['id']]['vol_f'] + 0.1 - 1
620620

621+
# test oversized overflowing deltas
622+
rv = client.patch('/api/zones', json={'zones': [z['id'] for z in zones], 'update': {'vol_delta_f': 10.0}})
623+
assert rv.status_code == HTTPStatus.OK
624+
jrv = rv.json()
625+
assert len(jrv['zones']) >= 6
626+
# check that each update worked as expected
627+
for z in jrv['zones']:
628+
if z['id'] in range(6):
629+
assert z['vol_f'] == amplipi.models.MAX_VOL_F
630+
assert z["vol_f_overflow"] == amplipi.models.MAX_VOL_F_OVERFLOW
631+
621632
# test overflow reset
622633
mid_vol_f = (amplipi.models.MIN_VOL_F + amplipi.models.MAX_VOL_F) / 2
623634
rv = client.patch('/api/zones', json={'zones': [z['id'] for z in zones], 'update': {'vol_f': mid_vol_f}})

0 commit comments

Comments
 (0)