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

Commit

Permalink
Add tests for dues and upcoming payments
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Dec 12, 2015
1 parent f469bc7 commit 6d2dff1
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion tests/py/test_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ def test_stripping_required_inputs(self):
assert self.db.one("SELECT COUNT(*) FROM teams") == 0
assert "Please fill out the 'Team Name' field." in r.body

# Migrate Tips
# ============

def test_migrate_tips_to_payment_instructions(self):
alice = self.make_participant('alice', claimed_time='now')
bob = self.make_participant('bob', claimed_time='now')
Expand Down Expand Up @@ -373,7 +376,40 @@ def test_migrate_tips_checks_for_multiple_teams(self):
assert len(payment_instructions) == 1


# cached values - receiving, nreceiving_from
# Dues, Upcoming Payment
# ======================

def test_get_dues(self):
alice = self.make_participant('alice', claimed_time='now', last_bill_result='')
bob = self.make_participant('bob', claimed_time='now', last_bill_result='Fail!')
team = self.make_team(is_approved=True)

alice.set_payment_instruction(team, '3.00') # Funded
bob.set_payment_instruction(team, '5.00') # Unfunded

# Simulate dues
self.db.run("UPDATE payment_instructions SET due = amount")

assert team.get_dues() == (3, 5)


def test_upcoming_payment(self):
alice = self.make_participant('alice', claimed_time='now', last_bill_result='')
bob = self.make_participant('bob', claimed_time='now', last_bill_result='')
carl = self.make_participant('carl', claimed_time='now', last_bill_result='Fail!')
team = self.make_team(is_approved=True)

alice.set_payment_instruction(team, '5.00') # Funded
bob.set_payment_instruction(team, '3.00') # Funded, but won't hit minimum charge
carl.set_payment_instruction(team, '10.00') # Unfunded

# Simulate dues
self.db.run("UPDATE payment_instructions SET due = amount")

assert team.get_upcoming_payment() == 10 # 2 * Alice's $5

# Cached Values
# =============

def test_receiving_only_includes_funded_payment_instructions(self):
alice = self.make_participant('alice', claimed_time='now', last_bill_result='')
Expand Down

0 comments on commit 6d2dff1

Please sign in to comment.