def test_add_backupdaterecalculate(self, mock): le = ULedger(0) mock.reset_mock() t = UTransaction(mocksubject(0), 0) le.add(t) assert mock.call_count == 0
def test_no_gold(self): le = ULedger(0) for i in range(0): t = UTransaction(mocksubject(-1), 0) le.add(t) assert le.recalculate() == (0.5, 0.5)
def test_add_legacyrecalculate(self, mock): le = ULedger(0) mock.reset_mock() t = UTransaction(mocksubject(0), 0) le.add(t) le.recalculate.assert_called_once_with()
def test_recalculate_gamma(self): le = ULedger(0) t = [ (0, 1, 0), (1, 1, 0), (2, 1, 0), (3, 1, 1), (4, 0, 0), (5, 0, 0), (6, 0, 0), (7, 0, 0), ] _ = [le.add(UTransaction(mocksubject(i, g), a)) for i, g, a in t] assert le.recalculate() == (9 / 14, 6 / 14)
def test_recalculate_1(self): le = ULedger(0) t0 = UTransaction(mocksubject(0, 0), 0) t1 = UTransaction(mocksubject(1, 1), 0) t2 = UTransaction(mocksubject(2, 1), 0) le.add(t0) le.add(t1) le.add(t2) assert le.recalculate() == (2 / 3, 1 / 4)
def test_score(self): le = ULedger(0) t0 = UTransaction(mocksubject(0, 1), 0) t1 = UTransaction(mocksubject(1, 1), 0) t2 = UTransaction(mocksubject(2, 1), 0) t3 = UTransaction(mocksubject(2, 1), 1) le.add(t0) le.add(t1) le.add(t2) le.add(t3) le.recalculate() assert le.score == (1 / 2, 2 / 5)
def test_add(self): le = ULedger(0) t = UTransaction(mocksubject(0), 0) le.add(t) assert t.gold is None