From 73b26a94170dd1991520acc09aa9a3c0c4a20700 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 24 Aug 2016 13:34:22 -0400 Subject: [PATCH] Start a test suite for grprbn* * get_ready_payout_routes_by_network --- tests/py/test_billing_exchanges.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/py/test_billing_exchanges.py b/tests/py/test_billing_exchanges.py index d5ec2bdf1a..13b8ae5118 100644 --- a/tests/py/test_billing_exchanges.py +++ b/tests/py/test_billing_exchanges.py @@ -12,8 +12,10 @@ capture_card_hold, create_card_hold, record_exchange, - record_exchange_result + record_exchange_result, + get_ready_payout_routes_by_network ) +from gratipay.billing.payday import Payday from gratipay.exceptions import NegativeBalance, NotWhitelisted from gratipay.models.exchange_route import ExchangeRoute from gratipay.testing import Foobar, Harness, D,P @@ -145,6 +147,30 @@ def test_capch_amount_under_minimum(self): assert self.obama.get_credit_card_error() == '' + # grprbn - get_ready_payout_routes_by_network + + @mock.patch.object(Payday, 'fetch_card_holds') + def run_payday(self, fch): + fch.return_value = {} + Payday.start().run() + + def test_grprbn_that_its_empty_to_start_with(self): + assert get_ready_payout_routes_by_network(self.db, 'paypal') == [] + + def test_grprbn_includes_team_owners(self): + enterprise = self.make_team(is_approved=True) + self.obama.set_payment_instruction(enterprise, 100) + self.run_payday() + routes = get_ready_payout_routes_by_network(self.db, 'paypal') + assert [r.participant.username for r in routes] == ['picard'] + + def test_grprbn_includes_1_0_payouts(self): + alice = self.make_participant('alice', balance=24, status_of_1_0_payout='pending-payout') + ExchangeRoute.insert(alice, 'paypal', 'alice@example.com') + routes = get_ready_payout_routes_by_network(self.db, 'paypal') + assert [r.participant.username for r in routes] == ['alice'] + + class TestsWithoutBillingHarness(Harness): def prep(self, amount):