Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Increase surface area of process_remainder test
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Aug 31, 2016
1 parent ee5bd7a commit 0ed1d31
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions tests/py/test_billing_payday.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,27 +423,38 @@ def test_process_payment_instructions(self):
assert payment.direction == 'to-team'

def test_process_remainder(self):
alice = self.make_participant('alice', claimed_time='now', balance=1)
picard = self.make_participant('picard', claimed_time='now', last_paypal_result='')
Enterprise = self.make_team('The Enterprise', picard, is_approved=True)
alice.set_payment_instruction(Enterprise, D('0.51'))
alice = self.make_participant('alice', claimed_time='now', balance=100)
picard = self.make_participant('picard', claimed_time='now', last_paypal_result='', verified_in='TT', email_address='[email protected]')
crusher = self.make_participant('crusher', claimed_time='now', verified_in='TT', email_address='[email protected]')

Enterprise = self.make_team('The Enterprise', picard, is_approved=True, available=100)
Enterprise.add_member(crusher, picard)
Enterprise.set_take_for(crusher, 10, crusher)
alice.set_payment_instruction(Enterprise, D('80'))

payday = Payday.start()
with self.db.get_cursor() as cursor:
payday.prepare(cursor)
payday.process_payment_instructions(cursor)
payday.process_remainder(cursor)
payday.process_takes(cursor, payday.ts_start)
payday.process_remainder(cursor)
assert cursor.one("select new_balance from payday_participants "
"where username='picard'") == D('0.51')
"where username='picard'") == D('70')
assert cursor.one("select balance from payday_teams where slug='TheEnterprise'") == 0
payday.update_balances(cursor)

assert P('alice').balance == D('0.49')
assert P('picard').balance == D('0.51')
assert P('alice').balance == D('20') # Alice had $100 and gave away $80
assert P('crusher').balance == D('10') # Crusher had set their take to $10
assert P('picard').balance == D('70') # Picard is the owner of the team, recieves what is leftover

payment = self.db.one("SELECT * FROM payments WHERE direction='to-participant'")
assert payment.amount == D('0.51')
payment_to_team = self.db.one("SELECT amount FROM payments WHERE direction='to-team'")
assert payment_to_team == D('80')

payments_to_participant = self.db.all("SELECT participant, amount FROM payments WHERE direction='to-participant' ORDER BY amount DESC")
assert payments_to_participant[0].participant == 'picard'
assert payments_to_participant[0].amount == D('70')
assert payments_to_participant[1].participant == 'crusher'
assert payments_to_participant[1].amount == D('10')

@pytest.mark.xfail(reason="team owners can't be taken over because of #3602")
def test_take_over_during_payin(self):
Expand Down

0 comments on commit 0ed1d31

Please sign in to comment.