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_backupdaterecalculate(self, mock): le = ULedger(0) mock.reset_mock() t = UTransaction(mocksubject(0), 0) le.add(t) assert mock.call_count == 0
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_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_recalculate_2(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) assert le.recalculate() == (1 / 2, 2 / 5)
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_add(self): le = ULedger(0) t = UTransaction(mocksubject(0), 0) le.add(t) assert t.gold is None
def test_init(self): le = ULedger(17) assert le.id == 17 assert type(le.no) is Counter assert type(le.yes) is Counter assert le._score == (0.5, 0.5)