def test_capch_partial_amount(self):
        self.hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check

        capture_card_hold(self.db, self.obama, D('15.00'), self.hold)
        assert self.obama.balance == P('obama').balance == D('15.00')
        assert self.obama.get_credit_card_error() == ''
    def test_capch_amount_under_minimum(self):
        self.hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check

        capture_card_hold(self.db, self.obama, D('0.01'), self.hold)
        assert self.obama.balance == P('obama').balance == D('9.41')
        assert self.obama.get_credit_card_error() == ''
    def test_capture_card_hold_amount_under_minimum(self):
        hold, error = create_card_hold(self.db, self.janet, D('20.00'))
        assert error == ''  # sanity check

        capture_card_hold(self.db, self.janet, D('0.01'), hold)
        janet = Participant.from_id(self.janet.id)
        assert self.janet.balance == janet.balance == D('9.41')
        assert self.janet.last_bill_result == janet.last_bill_result == ''
    def test_capture_card_hold_amount_under_minimum(self):
        hold, error = create_card_hold(self.db, self.janet, D("20.00"))
        assert error == ""  # sanity check

        capture_card_hold(self.db, self.janet, D("0.01"), hold)
        janet = Participant.from_id(self.janet.id)
        assert self.janet.balance == janet.balance == D("9.41")
        assert self.janet.last_bill_result == janet.last_bill_result == ""
Beispiel #5
0
    def test_capture_card_hold_partial_amount(self):
        hold, error = create_card_hold(self.db, self.janet, D('20.00'))
        assert error == ''  # sanity check

        capture_card_hold(self.db, self.janet, D('15.00'), hold)
        janet = Participant.from_id(self.janet.id)
        assert self.janet.balance == janet.balance == D('15.00')
        assert self.janet.get_credit_card_error() == ''
    def test_capture_card_hold_partial_amount(self):
        hold, error = create_card_hold(self.db, self.janet, D('20.00'))
        assert error == ''  # sanity check

        capture_card_hold(self.db, self.janet, D('15.00'), hold)
        janet = Participant.from_id(self.janet.id)
        assert self.janet.balance == janet.balance == D('15.00')
        assert self.janet.last_bill_result == janet.last_bill_result == ''
    def test_capture_card_hold_amount_under_minimum(self):
        hold, error = create_card_hold(self.db, self.janet, D('20.00'))
        assert error == ''  # sanity check

        capture_card_hold(self.db, self.janet, D('0.01'), hold)
        janet = Participant.from_id(self.janet.id)
        assert self.janet.balance == janet.balance == D('9.41')
        assert self.janet.get_credit_card_error() == ''
    def test_capch_too_high_amount(self):
        self.hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check

        with self.assertRaises(Exception):
            # How do I check the exception's msg here?
            capture_card_hold(self.db, self.obama, D('20.01'), self.hold)

        assert self.obama.balance == P('obama').balance == 0
    def test_capch_too_high_amount(self):
        self.hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check

        with self.assertRaises(Exception):
            # How do I check the exception's msg here?
            capture_card_hold(self.db, self.obama, D('20.01'), self.hold)

        assert self.obama.balance == P('obama').balance == 0
    def test_capch_full_amount(self):
        self.hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check
        assert self.hold.status == 'authorized'

        capture_card_hold(self.db, self.obama, D('20.00'), self.hold)
        hold = braintree.Transaction.find(self.hold.id)
        assert self.obama.balance == P('obama').balance == D('20.00')
        assert self.obama.get_credit_card_error() == ''
        assert hold.status == 'submitted_for_settlement'
    def test_capture_card_hold_full_amount(self):
        hold, error = create_card_hold(self.db, self.janet, D('20.00'))
        assert error == ''  # sanity check
        assert hold.meta['state'] == 'new'

        capture_card_hold(self.db, self.janet, D('20.00'), hold)
        janet = Participant.from_id(self.janet.id)
        assert self.janet.balance == janet.balance == D('20.00')
        assert self.janet.last_bill_result == janet.last_bill_result == ''
        assert hold.meta['state'] == 'captured'
    def test_capture_card_hold_full_amount(self):
        hold, error = create_card_hold(self.db, self.janet, D("20.00"))
        assert error == ""  # sanity check
        assert hold.meta["state"] == "new"

        capture_card_hold(self.db, self.janet, D("20.00"), hold)
        janet = Participant.from_id(self.janet.id)
        assert self.janet.balance == janet.balance == D("20.00")
        assert self.janet.last_bill_result == janet.last_bill_result == ""
        assert hold.meta["state"] == "captured"
    def test_capch_full_amount(self):
        self.hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check
        assert self.hold.status == 'authorized'

        capture_card_hold(self.db, self.obama, D('20.00'), self.hold)
        hold = braintree.Transaction.find(self.hold.id)
        assert self.obama.balance == P('obama').balance == D('20.00')
        assert self.obama.get_credit_card_error() == ''
        assert hold.status == 'submitted_for_settlement'
    def test_capture_card_hold_full_amount(self):
        hold, error = create_card_hold(self.db, self.janet, D('20.00'))
        assert error == ''  # sanity check
        assert hold.meta['state'] == 'new'

        capture_card_hold(self.db, self.janet, D('20.00'), hold)
        janet = Participant.from_id(self.janet.id)
        assert self.janet.balance == janet.balance == D('20.00')
        assert self.janet.get_credit_card_error() == ''
        assert hold.meta['state'] == 'captured'
    def test_capture_card_hold_partial_amount(self):
        hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check

        capture_card_hold(self.db, self.obama, D('15.00'), hold)
        obama = Participant.from_id(self.obama.id)
        assert self.obama.balance == obama.balance == D('15.00')
        assert self.obama.get_credit_card_error() == ''

        # Clean up
        cancel_card_hold(hold)
    def test_capture_card_hold_partial_amount(self):
        hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check

        capture_card_hold(self.db, self.obama, D('15.00'), hold)
        obama = Participant.from_id(self.obama.id)
        assert self.obama.balance == obama.balance == D('15.00')
        assert self.obama.get_credit_card_error() == ''

        # Clean up
        cancel_card_hold(hold)
    def test_capture_card_hold_too_high_amount(self):
        hold, error = create_card_hold(self.db, self.janet, D("20.00"))
        assert error == ""  # sanity check

        with self.assertRaises(balanced.exc.HTTPError):
            capture_card_hold(self.db, self.janet, D("20.01"), hold)

        janet = Participant.from_id(self.janet.id)
        assert self.janet.balance == janet.balance == 0

        # Clean up
        cancel_card_hold(hold)
    def test_capture_card_hold_too_high_amount(self):
        hold, error = create_card_hold(self.db, self.janet, D('20.00'))
        assert error == ''  # sanity check

        with self.assertRaises(balanced.exc.HTTPError):
            capture_card_hold(self.db, self.janet, D('20.01'), hold)

        janet = Participant.from_id(self.janet.id)
        assert self.janet.balance == janet.balance == 0

        # Clean up
        cancel_card_hold(hold)
    def test_capture_card_hold_too_high_amount(self):
        hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check

        with self.assertRaises(Exception):
            # How do I check the exception's msg here?
            capture_card_hold(self.db, self.obama, D('20.01'), hold)

        obama = Participant.from_id(self.obama.id)
        assert self.obama.balance == obama.balance == 0

        # Clean up
        cancel_card_hold(hold)
 def test_sync_with_balanced(self):
     with mock.patch("gratipay.billing.exchanges.record_exchange_result") as rer:
         rer.side_effect = Foobar()
         hold, error = create_card_hold(self.db, self.janet, D("20.00"))
         assert error == ""  # sanity check
         with self.assertRaises(Foobar):
             capture_card_hold(self.db, self.janet, D("10.00"), hold)
     exchange = self.db.one("SELECT * FROM exchanges")
     assert exchange.status == "pre"
     sync_with_balanced(self.db)
     exchange = self.db.one("SELECT * FROM exchanges")
     assert exchange.status == "succeeded"
     assert Participant.from_username("janet").balance == 10
    def test_capture_card_hold_too_high_amount(self):
        hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check

        with self.assertRaises(Exception):
            # How do I check the exception's msg here?
            capture_card_hold(self.db, self.obama, D('20.01'), hold)

        obama = Participant.from_id(self.obama.id)
        assert self.obama.balance == obama.balance == 0

        # Clean up
        cancel_card_hold(hold)
 def test_sync_with_balanced(self):
     with mock.patch('gratipay.billing.exchanges.record_exchange_result') as rer:
         rer.side_effect = Foobar()
         hold, error = create_card_hold(self.db, self.janet, D('20.00'))
         assert error == ''  # sanity check
         with self.assertRaises(Foobar):
             capture_card_hold(self.db, self.janet, D('10.00'), hold)
     exchange = self.db.one("SELECT * FROM exchanges")
     assert exchange.status == 'pre'
     sync_with_balanced(self.db)
     exchange = self.db.one("SELECT * FROM exchanges")
     assert exchange.status == 'succeeded'
     assert Participant.from_username('janet').balance == 10
    def test_capture_card_hold_full_amount(self):
        hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check
        assert hold.status == 'authorized'

        capture_card_hold(self.db, self.obama, D('20.00'), hold)
        hold = braintree.Transaction.find(hold.id)
        obama = Participant.from_id(self.obama.id)
        assert self.obama.balance == obama.balance == D('20.00')
        assert self.obama.get_credit_card_error() == ''
        assert hold.status == 'submitted_for_settlement'

        # Clean up
        cancel_card_hold(hold)
 def test_sync_with_balanced_deletes_charges_that_didnt_happen(self):
     with mock.patch('gratipay.billing.exchanges.record_exchange_result') as rer \
        , mock.patch('balanced.CardHold.capture') as capture:
         rer.side_effect = capture.side_effect = Foobar
         hold, error = create_card_hold(self.db, self.janet, D('33.67'))
         assert error == ''  # sanity check
         with self.assertRaises(Foobar):
             capture_card_hold(self.db, self.janet, D('7.52'), hold)
     exchange = self.db.one("SELECT * FROM exchanges")
     assert exchange.status == 'pre'
     sync_with_balanced(self.db)
     exchanges = self.db.all("SELECT * FROM exchanges")
     assert not exchanges
     assert Participant.from_username('janet').balance == 0
    def test_capture_card_hold_full_amount(self):
        hold, error = create_card_hold(self.db, self.obama, D('20.00'))
        assert error == ''  # sanity check
        assert hold.status == 'authorized'

        capture_card_hold(self.db, self.obama, D('20.00'), hold)
        hold = braintree.Transaction.find(hold.id)
        obama = Participant.from_id(self.obama.id)
        assert self.obama.balance == obama.balance == D('20.00')
        assert self.obama.get_credit_card_error() == ''
        assert hold.status == 'submitted_for_settlement'

        # Clean up
        cancel_card_hold(hold)
 def test_sync_with_balanced_deletes_charges_that_didnt_happen(self):
     with mock.patch('gratipay.billing.exchanges.record_exchange_result') as rer \
        , mock.patch('balanced.CardHold.capture') as capture:
         rer.side_effect = capture.side_effect = Foobar
         hold, error = create_card_hold(self.db, self.janet, D('33.67'))
         assert error == ''  # sanity check
         with self.assertRaises(Foobar):
             capture_card_hold(self.db, self.janet, D('7.52'), hold)
     exchange = self.db.one("SELECT * FROM exchanges")
     assert exchange.status == 'pre'
     sync_with_balanced(self.db)
     exchanges = self.db.all("SELECT * FROM exchanges")
     assert not exchanges
     assert Participant.from_username('janet').balance == 0
Beispiel #27
0
 def capture(p):
     amount = -p.new_balance
     capture_card_hold(self.db, p, amount, holds.pop(p.id))
Beispiel #28
0
 def capture(p):
     amount = -p.new_balance
     capture_card_hold(self.db, p, amount, holds.pop(p.id))