本文整理汇总了Python中gratipay.models.exchange_route.ExchangeRoute类的典型用法代码示例。如果您正苦于以下问题:Python ExchangeRoute类的具体用法?Python ExchangeRoute怎么用?Python ExchangeRoute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExchangeRoute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
# Balanced Customer without funding instruments
self.david = self.make_participant('david', is_suspicious=False,
claimed_time='now',
balanced_customer_href=self.david_href)
# Balanced Customer with CC attached
self.janet = self.make_participant('janet', is_suspicious=False,
claimed_time='now',
balanced_customer_href=self.janet_href)
self.janet_route = ExchangeRoute.insert(self.janet, 'balanced-cc', self.card_href)
# Balanced Customer with BA attached
self.homer = self.make_participant('homer', is_suspicious=False,
claimed_time='now',
balanced_customer_href=self.homer_href)
self.homer_route = ExchangeRoute.insert(self.homer, 'balanced-ba', self.bank_account_href)
# Braintree Customer without funding instruments
self.roman = self.make_participant('roman', is_suspicious=False,
claimed_time='now',
braintree_customer_id=self.roman_bt_id)
# Braintree Customer with CC attached
self.obama = self.make_participant('obama', is_suspicious=False,
claimed_time='now',
braintree_customer_id=self.obama_bt_id)
self.obama_route = ExchangeRoute.insert(self.obama, 'braintree-cc', self.obama_cc_token)
示例2: test_credit_callback
def test_credit_callback(self, rer):
alice = self.make_participant('alice')
ExchangeRoute.insert(alice, 'balanced-ba', '/bank/foo', '')
ba = ExchangeRoute.from_network(alice, 'balanced-ba')
for status in ('succeeded', 'failed'):
error = 'FOO' if status == 'failed' else None
e_id = record_exchange(self.db, ba, 10, 0, alice, 'pre')
body = json.dumps({
"events": [
{
"type": "credit."+status,
"entity": {
"credits": [
{
"failure_reason": error,
"meta": {
"participant_id": alice.id,
"exchange_id": e_id,
},
"status": status,
}
]
}
}
]
})
r = self.callback(body=body, csrf_token=False)
assert r.code == 200, r.body
assert rer.call_count == 1
assert rer.call_args[0][:-1] == (self.db, e_id, status, error)
assert rer.call_args[0][-1].id == alice.id
assert rer.call_args[1] == {}
rer.reset_mock()
示例3: test_grprbn_includes_1_0_payouts
def test_grprbn_includes_1_0_payouts(self):
alice = self.make_participant( 'alice'
, balance=24
, status_of_1_0_payout='pending-payout'
, claimed_time='now'
)
ExchangeRoute.insert(alice, 'paypal', '[email protected]')
routes = get_ready_payout_routes_by_network(self.db, 'paypal')
assert [r.participant.username for r in routes] == ['alice']
示例4: make_exchange
def make_exchange(self, route, amount, fee, participant, status='succeeded', error=''):
if not isinstance(route, ExchangeRoute):
network = route
route = ExchangeRoute.from_network(participant, network)
if not route:
route = ExchangeRoute.insert(participant, network, 'dummy-address')
assert route
e_id = record_exchange(self.db, route, amount, fee, participant, 'pre')
record_exchange_result(self.db, e_id, status, error, participant)
return e_id
示例5: make_exchange
def make_exchange(self, route, amount, fee, participant, status='succeeded', error=''):
if not isinstance(route, ExchangeRoute):
network = route
route = ExchangeRoute.from_network(participant, network)
if not route:
from .balanced import BalancedHarness
route = ExchangeRoute.insert(participant, network, BalancedHarness.card_href)
assert route
e_id = record_exchange(self.db, route, amount, fee, participant, 'pre')
record_exchange_result(self.db, e_id, status, error, participant)
return e_id
示例6: setUp
def setUp(self):
self.david = self.make_participant('david', is_suspicious=False,
claimed_time='now',
balanced_customer_href=self.david_href)
self.janet = self.make_participant('janet', is_suspicious=False,
claimed_time='now',
balanced_customer_href=self.janet_href)
self.janet_route = ExchangeRoute.insert(self.janet, 'balanced-cc', self.card_href)
self.homer = self.make_participant('homer', is_suspicious=False,
claimed_time='now',
balanced_customer_href=self.homer_href)
self.homer_route = ExchangeRoute.insert(self.homer, 'balanced-ba', self.bank_account_href)
示例7: test_create_card_hold_bad_card
def test_create_card_hold_bad_card(self):
bob = self.make_participant('bob', balanced_customer_href='new',
is_suspicious=False)
card = balanced.Card(
number='4444444444444448',
expiration_year=2020,
expiration_month=12
).save()
card.associate_to_customer(bob.balanced_customer_href)
ExchangeRoute.insert(bob, 'balanced-cc', card.href)
hold, error = create_card_hold(self.db, bob, D('10.00'))
assert error.startswith('402 Payment Required, ')
示例8: test_giving_is_updated_when_credit_card_fails
def test_giving_is_updated_when_credit_card_fails(self, btd):
alice = self.make_participant("alice", claimed_time="now", last_bill_result="")
team = self.make_team(is_approved=True)
alice.set_payment_instruction(team, "5.00") # funded
assert alice.giving == Decimal("5.00")
assert Team.from_slug(team.slug).receiving == Decimal("5.00")
ExchangeRoute.from_network(alice, "braintree-cc").update_error("Card expired")
assert Participant.from_username("alice").giving == Decimal("0.00")
assert Team.from_slug(team.slug).receiving == Decimal("0.00")
示例9: make_exchange
def make_exchange(self, route, amount, fee, participant, status='succeeded', error='',
ref='dummy-trans-id', address='dummy-address'):
"""Factory for exchanges.
"""
if not isinstance(route, ExchangeRoute):
network = route
route = ExchangeRoute.from_network(participant, network)
if not route:
route = ExchangeRoute.insert(participant, network, address)
assert route
e_id = record_exchange(self.db, route, amount, fee, participant, 'pre', ref)
record_exchange_result(self.db, e_id, status, error, participant)
return e_id
示例10: test_cch_multiple_cards
def test_cch_multiple_cards(self):
bob = self.make_participant('bob', is_suspicious=False)
customer_id = bob.get_braintree_account().id
for i in range(2):
result = braintree.PaymentMethod.create({
"customer_id": customer_id,
"payment_method_nonce": Nonces.Transactable
})
assert result.is_success
ExchangeRoute.insert(bob, 'braintree-cc', result.payment_method.token)
self.hold, error = create_card_hold(self.db, bob, D('100.00'))
assert error == ''
示例11: setUp
def setUp(self):
# Braintree Customer without funding instruments
self.roman = self.make_participant('roman', is_suspicious=False,
claimed_time='now',
braintree_customer_id=self.roman_bt_id)
# Braintree Customer with CC attached
self.obama = self.make_participant('obama', is_suspicious=False,
claimed_time='now',
braintree_customer_id=self.obama_bt_id)
self.obama_route = ExchangeRoute.insert(self.obama, 'braintree-cc', self.obama_cc_token)
# A customer with Paypal attached.
self.homer = self.make_participant('homer', is_suspicious=False,
claimed_time='now')
self.homer_route = ExchangeRoute.insert(self.homer, 'paypal', '[email protected]')
示例12: test_giving_is_updated_when_credit_card_fails
def test_giving_is_updated_when_credit_card_fails(self, btd):
alice = self.make_participant('alice', claimed_time='now', last_bill_result='')
team = self.make_team(is_approved=True)
alice.set_payment_instruction(team, '5.00') # funded
assert alice.giving == Decimal('5.00')
assert Team.from_slug(team.slug).receiving == Decimal('5.00')
assert Participant.from_username(team.owner).taking == Decimal('5.00')
ExchangeRoute.from_network(alice, 'braintree-cc').update_error("Card expired")
assert Participant.from_username('alice').giving == Decimal('0.00')
assert Team.from_slug(team.slug).receiving == Decimal('0.00')
assert Participant.from_username(team.owner).taking == Decimal('0.00')
示例13: test_giving_is_updated_when_credit_card_is_updated
def test_giving_is_updated_when_credit_card_is_updated(self, btd):
alice = self.make_participant('alice', claimed_time='now', last_bill_result='fail')
team = self.make_team(is_approved=True)
alice.set_payment_instruction(team, '5.00') # Not funded, failing card
assert alice.giving == Decimal('0.00')
assert Team.from_slug(team.slug).receiving == Decimal('0.00')
# Alice updates her card..
ExchangeRoute.from_network(alice, 'braintree-cc').invalidate()
ExchangeRoute.insert(alice, 'braintree-cc', '/cards/bar', '')
assert alice.giving == Decimal('5.00')
assert Team.from_slug(team.slug).receiving == Decimal('5.00')
示例14: test_giving_is_updated_when_credit_card_is_updated
def test_giving_is_updated_when_credit_card_is_updated(self, btd):
alice = self.make_participant("alice", claimed_time="now", last_bill_result="fail")
team = self.make_team(is_approved=True)
alice.set_payment_instruction(team, "5.00") # Not funded, failing card
assert alice.giving == Decimal("0.00")
assert Team.from_slug(team.slug).receiving == Decimal("0.00")
# Alice updates her card..
ExchangeRoute.from_network(alice, "braintree-cc").invalidate()
ExchangeRoute.insert(alice, "braintree-cc", "/cards/bar", "")
assert alice.giving == Decimal("5.00")
assert Team.from_slug(team.slug).receiving == Decimal("5.00")
示例15: test_cch_bad_card
def test_cch_bad_card(self):
bob = self.make_participant('bob', is_suspicious=False)
customer_id = bob.get_braintree_account().id
result = braintree.PaymentMethod.create({
"customer_id": customer_id,
"payment_method_nonce": Nonces.Transactable
})
assert result.is_success
ExchangeRoute.insert(bob, 'braintree-cc', result.payment_method.token)
# https://developers.braintreepayments.com/ios+python/reference/general/testing#test-amounts
# $2002 is upcharged to $2062, which corresponds to 'Invalid Tax Amount'
self.hold, error = create_card_hold(self.db, bob, D('2002.00'))
assert self.hold is None
assert error.startswith('Invalid Tax Amount')