From 1d6cf8e9876da169c5bb6071949a9587130d2f94 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 15 May 2014 08:21:33 -0400 Subject: [PATCH] Failing tests for pachinko bugs during #2362 --- tests/py/test_billing_payday.py | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/tests/py/test_billing_payday.py b/tests/py/test_billing_payday.py index 6a8e4b649f..a6684c476f 100644 --- a/tests/py/test_billing_payday.py +++ b/tests/py/test_billing_payday.py @@ -838,7 +838,8 @@ def test_get_participants_gets_participants(self): assert actual == expected def test_pachinko_pachinkos(self): - a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20, pending=0) + a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20, \ + pending=0) a_team.add_member(self.make_participant('alice', claimed_time='now', balance=0, pending=0)) a_team.add_member(self.make_participant('bob', claimed_time='now', balance=0, pending=0)) @@ -846,3 +847,51 @@ def test_pachinko_pachinkos(self): participants = self.payday.genparticipants(ts_start, ts_start) self.payday.pachinko(ts_start, participants) + + assert Participant.from_username('alice').pending == D('0.01') + assert Participant.from_username('bob').pending == D('0.01') + + def test_pachinko_sees_current_take(self): + a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20, \ + pending=0) + alice = self.make_participant('alice', claimed_time='now', balance=0, pending=0) + a_team.add_member(alice) + a_team.set_take_for(alice, D('1.00'), alice) + + ts_start = self.payday.start() + + participants = self.payday.genparticipants(ts_start, ts_start) + self.payday.pachinko(ts_start, participants) + + assert Participant.from_username('alice').pending == D('1.00') + + def test_pachinko_ignores_take_set_after_payday_starts(self): + a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20, \ + pending=0) + alice = self.make_participant('alice', claimed_time='now', balance=0, pending=0) + a_team.add_member(alice) + a_team.set_take_for(alice, D('0.33'), alice) + + ts_start = self.payday.start() + a_team.set_take_for(alice, D('1.00'), alice) + + participants = self.payday.genparticipants(ts_start, ts_start) + self.payday.pachinko(ts_start, participants) + + assert Participant.from_username('alice').pending == D('0.33') + + def test_pachinko_ignores_take_thats_already_been_processed(self): + a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20, \ + pending=0) + alice = self.make_participant('alice', claimed_time='now', balance=0, pending=0) + a_team.add_member(alice) + a_team.set_take_for(alice, D('0.33'), alice) + + ts_start = self.payday.start() + a_team.set_take_for(alice, D('1.00'), alice) + + for i in range(4): + participants = self.payday.genparticipants(ts_start, ts_start) + self.payday.pachinko(ts_start, participants) + + assert Participant.from_username('alice').pending == D('0.33')