Shadow-mode client script and cutover doc correction
This commit is contained in:
@@ -99,6 +99,58 @@ def test_days_left_never_goes_negative():
|
||||
assert result['daysleft'] == 0
|
||||
|
||||
|
||||
def test_live_level_drives_the_countdown_not_the_stored_one():
|
||||
"""The report shows the live level, so it must count down from that one.
|
||||
|
||||
History lags a poll, and trends lag an hour. Displaying 20% beside a
|
||||
countdown computed from a stored 4% is how a report loses its reader.
|
||||
"""
|
||||
result = analyse(series([100, 80, 60, 40]), currentlevel=20)
|
||||
|
||||
assert result['currentlevel'] == 20
|
||||
assert result['burnrateperday'] == 20.0 # 60 points over 3 days
|
||||
assert result['daysleft'] == 1 # 20 / 20, not 40 / 20
|
||||
|
||||
|
||||
def test_a_nearly_empty_cartridge_reads_as_empty_not_as_weeks_away():
|
||||
"""1% draining a tenth of a point a day computes to ten days. It is out."""
|
||||
result = analyse(series([2.0, 1.7, 1.4, 1.1]), currentlevel=1)
|
||||
|
||||
assert result['daysleft'] == 0
|
||||
|
||||
|
||||
def test_empty_sorts_ahead_of_a_fast_healthy_cartridge():
|
||||
empty = analyse(series([2.0, 1.7, 1.4, 1.1]), currentlevel=1)
|
||||
healthy = analyse(series([100, 80, 60, 40]))
|
||||
|
||||
assert empty['daysleft'] < healthy['daysleft']
|
||||
|
||||
|
||||
def test_a_low_live_level_is_actionable_without_any_history():
|
||||
"""A printer new to Zabbix still reports it is out of toner."""
|
||||
result = analyse([], currentlevel=1)
|
||||
|
||||
assert result['daysleft'] == 0
|
||||
assert result['reason'] is None
|
||||
|
||||
|
||||
def test_no_history_and_a_healthy_level_still_says_no_history():
|
||||
result = analyse([], currentlevel=80)
|
||||
|
||||
assert result['daysleft'] is None
|
||||
assert result['reason'] == 'no history'
|
||||
|
||||
|
||||
def test_a_live_level_above_the_stored_run_means_it_was_just_swapped():
|
||||
"""Trends lag an hour; a cartridge changed in that hour must not inherit
|
||||
the rate of the one that came out."""
|
||||
result = analyse(series([40, 30, 20, 10]), currentlevel=100)
|
||||
|
||||
assert result['daysleft'] is None
|
||||
assert result['reason'] == 'replaced recently'
|
||||
assert result['replacements'] == 1
|
||||
|
||||
|
||||
def test_printer_sorts_by_its_soonest_supply():
|
||||
"""A colour MFP is as urgent as its most pressing cartridge."""
|
||||
supplies = [{'daysleft': 40}, {'daysleft': 6}, {'daysleft': None}]
|
||||
|
||||
Reference in New Issue
Block a user