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

Commit

Permalink
modify test to avoid test fixtures and cover both email simplates
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Apr 9, 2015
1 parent c2cee2d commit bd5f789
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions tests/py/test_billing_payday.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from gratipay.models.participant import Participant
from gratipay.testing import Foobar, Harness
from gratipay.testing.balanced import BalancedHarness
from gratipay.testing.emails import EmailHarness


class TestPayday(BalancedHarness):
Expand Down Expand Up @@ -529,16 +530,22 @@ def test_payout_ach_error(self, ach_credit):
assert payday['nach_failing'] == 1


class TestNotifyParticipants(BalancedHarness):
class TestNotifyParticipants(EmailHarness):

@mock.patch.object(Payday, 'fetch_card_holds')
def test_it_notifies_participants(self, fch):
self.janet.set_tip_to(self.homer, D('10.00'))
fch.return_value = {}
Payday.start().run()
def test_it_notifies_participants(self):
kalel = self.make_participant('kalel', claimed_time='now', is_suspicious=False,
email_address='[email protected]', notify_charge=3)
lily = self.make_participant('lily', claimed_time='now', is_suspicious=False)
kalel.set_tip_to(lily, 10)

for status in ('failed', 'succeeded'):
payday = Payday.start()
self.make_exchange('balanced-cc', 10, 0, kalel, status)
payday.end()
payday.notify_participants()

exchanges = self.db.one('SELECT * FROM exchanges')
assert exchanges['amount'] == D('10.00')
emails = self.db.one('SELECT * FROM email_queue')
assert emails.spt_name == 'charge_'+status

emails = self.db.one('SELECT * FROM email_queue')
assert emails['spt_name'] == 'charge_succeeded'
Participant.dequeue_emails()
assert self.get_last_email()['to'][0]['email'] == '[email protected]'

0 comments on commit bd5f789

Please sign in to comment.