def test_sync_with_balanced_reverts_credits_that_didnt_happen(self):
     self.make_exchange('bill', 41, 0, self.homer)
     with mock.patch('gratipay.billing.exchanges.record_exchange_result') as rer \
        , mock.patch('balanced.Customer') as Customer:
         rer.side_effect = Customer.side_effect = Foobar
         with self.assertRaises(Foobar):
             ach_credit(self.db, self.homer, 0, 0)
     exchange = self.db.one("SELECT * FROM exchanges WHERE amount < 0")
     assert exchange.status == 'pre'
     sync_with_balanced(self.db)
     exchanges = self.db.all("SELECT * FROM exchanges WHERE amount < 0")
     assert not exchanges
     assert Participant.from_username('homer').balance == 41
 def test_sync_with_balanced_reverts_credits_that_didnt_happen(self):
     self.make_exchange('balanced-cc', 41, 0, self.homer)
     with mock.patch('gratipay.billing.exchanges.record_exchange_result') as rer \
        , mock.patch('gratipay.billing.exchanges.thing_from_href') as tfh:
         rer.side_effect = tfh.side_effect = Foobar
         with self.assertRaises(Foobar):
             ach_credit(self.db, self.homer, 0, 0)
     exchange = self.db.one("SELECT * FROM exchanges WHERE amount < 0")
     assert exchange.status == 'pre'
     sync_with_balanced(self.db)
     exchanges = self.db.all("SELECT * FROM exchanges WHERE amount < 0")
     assert not exchanges
     assert Participant.from_username('homer').balance == 41
Пример #3
0
 def test_sync_with_balanced_reverts_credits_that_didnt_happen(self):
     self.make_exchange("bill", 41, 0, self.homer)
     with mock.patch("gratipay.billing.exchanges.record_exchange_result") as rer, mock.patch(
         "balanced.Customer"
     ) as Customer:
         rer.side_effect = Customer.side_effect = Foobar
         with self.assertRaises(Foobar):
             ach_credit(self.db, self.homer, 0, 0)
     exchange = self.db.one("SELECT * FROM exchanges WHERE amount < 0")
     assert exchange.status == "pre"
     sync_with_balanced(self.db)
     exchanges = self.db.all("SELECT * FROM exchanges WHERE amount < 0")
     assert not exchanges
     assert Participant.from_username("homer").balance == 41
Пример #4
0
 def test_ach_credit_invalidated_bank_account(self):
     bob = self.make_participant('bob',
                                 is_suspicious=False,
                                 balance=20,
                                 last_ach_result='invalidated')
     error = ach_credit(self.db, bob, D('1.00'))
     assert error == 'No bank account'
Пример #5
0
 def test_ach_credit_failure(self, tfh):
     tfh.side_effect = Foobar
     self.make_exchange('balanced-cc', 20, 0, self.homer)
     error = ach_credit(self.db, self.homer, D('1.00'))
     homer = Participant.from_id(self.homer.id)
     assert self.homer.get_bank_account_error() == error == "Foobar()"
     assert self.homer.balance == homer.balance == 20
Пример #6
0
 def test_ach_credit_withhold(self):
     self.make_exchange('balanced-cc', 27, 0, self.homer)
     withhold = D('1.00')
     error = ach_credit(self.db, self.homer, withhold)
     assert error == ''
     homer = Participant.from_id(self.homer.id)
     assert self.homer.balance == homer.balance == 1
 def test_ach_credit_withhold(self):
     self.make_exchange('balanced-cc', 27, 0, self.homer)
     withhold = D('1.00')
     error = ach_credit(self.db, self.homer, withhold)
     assert error == ''
     homer = Participant.from_id(self.homer.id)
     assert self.homer.balance == homer.balance == 1
 def test_ach_credit_failure(self, tfh):
     tfh.side_effect = Foobar
     self.make_exchange('balanced-cc', 20, 0, self.homer)
     error = ach_credit(self.db, self.homer, D('1.00'))
     homer = Participant.from_id(self.homer.id)
     assert self.homer.get_bank_account_error() == error == "Foobar()"
     assert self.homer.balance == homer.balance == 20
Пример #9
0
 def credit(participant):
     if participant.is_suspicious is None:
         log("UNREVIEWED: %s" % participant.username)
         return
     withhold = participant.giving + participant.pledging
     error = ach_credit(self.db, participant, withhold)
     if error:
         self.mark_ach_failed()
Пример #10
0
 def credit(route):
     if route.participant.is_suspicious is None:
         log("UNREVIEWED: %s" % route.participant.username)
         return
     withhold = route.participant.giving
     error = ach_credit(self.db, route.participant, withhold)
     if error:
         self.mark_ach_failed()
 def test_ach_credit_amount_under_minimum(self):
     bob = self.make_participant('bob',
                                 last_ach_result="failure",
                                 balance=8,
                                 balanced_customer_href=self.homer_href,
                                 is_suspicious=False)
     r = ach_credit(self.db, bob, 0)
     assert r is None
Пример #12
0
 def credit(participant):
     if participant.is_suspicious is None:
         log("UNREVIEWED: %s" % participant.username)
         return
     withhold = participant.giving + participant.pledging
     error = ach_credit(self.db, participant, withhold)
     if error:
         self.mark_ach_failed()
 def test_ach_credit_withhold(self):
     bob = self.make_participant('bob', last_ach_result="failure", balance=20,
                                 balanced_customer_href=self.homer_href,
                                 is_suspicious=False)
     withhold = D('1.00')
     error = ach_credit(self.db, bob, withhold)
     assert error == ''
     bob2 = Participant.from_id(bob.id)
     assert bob.balance == bob2.balance == 1
Пример #14
0
 def test_ach_credit_withhold(self):
     bob = self.make_participant(
         "bob", last_ach_result="failure", balance=20, balanced_customer_href=self.homer_href, is_suspicious=False
     )
     withhold = D("1.00")
     error = ach_credit(self.db, bob, withhold)
     assert error == ""
     bob2 = Participant.from_id(bob.id)
     assert bob.balance == bob2.balance == 1
    def test_ach_credit_failure(self, Customer):
        Customer.side_effect = Foobar
        bob = self.make_participant('bob', last_ach_result="failure", balance=20,
                                    balanced_customer_href=self.homer_href,
                                    is_suspicious=False)

        error = ach_credit(self.db, bob, D('1.00'))
        bob2 = Participant.from_id(bob.id)
        assert bob.last_ach_result == bob2.last_ach_result == error == "Foobar()"
        assert bob.balance == bob2.balance == 20
Пример #16
0
    def test_ach_credit_failure(self, Customer):
        Customer.side_effect = Foobar
        bob = self.make_participant(
            "bob", last_ach_result="failure", balance=20, balanced_customer_href=self.homer_href, is_suspicious=False
        )

        error = ach_credit(self.db, bob, D("1.00"))
        bob2 = Participant.from_id(bob.id)
        assert bob.last_ach_result == bob2.last_ach_result == error == "Foobar()"
        assert bob.balance == bob2.balance == 20
 def test_ach_credit_no_bank_account(self):
     self.make_exchange('balanced-cc', 20, 0, self.david)
     error = ach_credit(self.db, self.david, D('1.00'))
     assert error == 'No bank account'
Пример #18
0
 def test_ach_credit_no_bank_account(self):
     self.make_exchange("bill", 20, 0, self.david)
     error = ach_credit(self.db, self.david, D("1.00"))
     david = Participant.from_username("david")
     assert error == "NoResultFound()"
     assert self.david.last_ach_result == david.last_ach_result == None
Пример #19
0
 def test_ach_credit_no_bank_account(self):
     self.make_exchange('balanced-cc', 20, 0, self.david)
     error = ach_credit(self.db, self.david, D('1.00'))
     assert error == 'No bank account'
Пример #20
0
 def test_ach_credit_amount_under_minimum(self):
     bob = self.make_participant(
         "bob", last_ach_result="failure", balance=8, balanced_customer_href=self.homer_href, is_suspicious=False
     )
     r = ach_credit(self.db, bob, 0)
     assert r is None
 def test_ach_credit_no_bank_account(self):
     self.make_exchange('bill', 20, 0, self.david)
     error = ach_credit(self.db, self.david, D('1.00'))
     david = Participant.from_username('david')
     assert error == 'NoResultFound()'
     assert self.david.last_ach_result == david.last_ach_result == None
 def test_ach_credit_no_bank_account(self):
     self.make_exchange('bill', 20, 0, self.david)
     error = ach_credit(self.db, self.david, D('1.00'))
     david = Participant.from_username('david')
     assert error == 'NoResultFound()'
     assert self.david.last_ach_result == david.last_ach_result == None
Пример #23
0
 def test_ach_credit_amount_under_minimum(self):
     self.make_exchange('balanced-cc', 8, 0, self.homer)
     r = ach_credit(self.db, self.homer, 0)
     assert r is None
 def test_ach_credit_invalidated_bank_account(self):
     bob = self.make_participant('bob', is_suspicious=False, balance=20,
                                 last_ach_result='invalidated')
     error = ach_credit(self.db, bob, D('1.00'))
     assert error == 'No bank account'
 def test_ach_credit_amount_under_minimum(self):
     self.make_exchange('balanced-cc', 8, 0, self.homer)
     r = ach_credit(self.db, self.homer, 0)
     assert r is None