Preserve August hydrogen revision and September audit evidence; calculate interrupted vehicle history across all prior months. Record remaining carry-policy and layout-baseline discrepancies.
34 lines
1.7 KiB
Python
34 lines
1.7 KiB
Python
"""Regression checks: reappearing vehicles must not bypass past shortfalls."""
|
|
import copy
|
|
import unittest
|
|
import calc_engine as e
|
|
|
|
KEY=('测试车','原负责人')
|
|
def group(target,actual,paid=False):
|
|
return dict(应考核=target,实际=actual,奖金=150 if actual>=target else 0,
|
|
天数=30,有达标=actual>=target,目标km=3000,奖励达标=150,
|
|
奖励结转=150,奖励补发=150,部门='测试部门',销售=KEY[1],车牌=KEY[0],
|
|
recs=[],可结转=0,累计已发结转=0,**{'1月已发':paid})
|
|
def run_case(past,now,prev=None):
|
|
h={m:{} for m in range(1,10)};h[1][KEY]=past;h[9][KEY]=now
|
|
if prev:h[8][KEY]=prev
|
|
payments={};e.calc_month(9,h,payments,h[8],h[9],cumulative_history=True)
|
|
return h[9][KEY],payments[9]
|
|
class InterruptedHistory(unittest.TestCase):
|
|
def test_current_pass_does_not_erase_old_deficit(self):
|
|
g,p=run_case(group(3000,100),group(3000,3100))
|
|
self.assertEqual((g['cum_t'],g['cum_a']),(6000,3200))
|
|
self.assertFalse(p['补发1月']);self.assertTrue(p['当月'])
|
|
def test_full_history_pass_unlocks_unpaid_month(self):
|
|
g,p=run_case(group(3000,1000),group(3000,5000))
|
|
self.assertTrue(g['cum_q']);self.assertTrue(p['补发1月'])
|
|
def test_settled_month_is_not_paid_twice(self):
|
|
_,p=run_case(group(3000,1000,paid=True),group(3000,5000))
|
|
self.assertFalse(p['补发1月'])
|
|
def test_cumulative_snapshot_cannot_hide_earlier_months(self):
|
|
prev=group(3000,3000);prev.update(cum_t=3000,cum_a=3000)
|
|
g,p=run_case(group(3000,100),group(3000,3100),prev)
|
|
self.assertEqual((g['cum_t'],g['cum_a']),(9000,6200))
|
|
self.assertFalse(p['补发1月'])
|
|
if __name__=='__main__':unittest.main()
|