From bd5f789323b6ab44a162b3df27a4d4d1fa263a23 Mon Sep 17 00:00:00 2001 From: Changaco Date: Thu, 9 Apr 2015 10:46:19 +0200 Subject: [PATCH] modify test to avoid test fixtures and cover both email simplates --- tests/py/test_billing_payday.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tests/py/test_billing_payday.py b/tests/py/test_billing_payday.py index 0414cc9941..5bb4a82730 100644 --- a/tests/py/test_billing_payday.py +++ b/tests/py/test_billing_payday.py @@ -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): @@ -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='kalel@example.net', 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'] == 'kalel@example.net'