Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Cleanup Balanced Harness
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed May 9, 2015
1 parent f0c2950 commit 40bbf50
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 40 deletions.
3 changes: 1 addition & 2 deletions gratipay/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def make_exchange(self, route, amount, fee, participant, status='succeeded', err
network = route
route = ExchangeRoute.from_network(participant, network)
if not route:
from .balanced import BalancedHarness
route = ExchangeRoute.insert(participant, network, BalancedHarness.card_href)
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)
Expand Down
81 changes: 43 additions & 38 deletions gratipay/testing/balanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,49 @@ def setUp(self):
balanced_customer_href=self.homer_href)
self.homer_route = ExchangeRoute.insert(self.homer, 'balanced-ba', self.bank_account_href)

@classmethod
def setUpClass(cls):
with use_cassette('BalancedHarness'):
balanced.configure(balanced.APIKey().save().secret)
mp = balanced.Marketplace.my_marketplace
if not mp:
mp = balanced.Marketplace().save()
cls.balanced_marketplace = mp

cls.david_href = cls.make_balanced_customer()

cls.janet_href = cls.make_balanced_customer()
cls.card = balanced.Card(
number='4111111111111111',
expiration_month=10,
expiration_year=2020,
address={
'line1': "123 Main Street",
'state': 'Confusion',
'postal_code': '90210',
},
# gratipay stores some of the address data in the meta fields,
# continue using them to support backwards compatibility
meta={
'address_2': 'Box 2',
'city_town': '',
'region': 'Confusion',
}
).save()
cls.card.associate_to_customer(cls.janet_href)
cls.card_href = unicode(cls.card.href)

cls.homer_href = cls.make_balanced_customer()
cls.bank_account = balanced.BankAccount(
name='Homer Jay',
account_number='112233a',
routing_number='121042882',
).save()
cls.bank_account.associate_to_customer(cls.homer_href)
cls.bank_account_href = unicode(cls.bank_account.href)

super(BalancedHarness, cls).setUpClass()

@classmethod
def tearDownClass(cls):
has_exchange_id = balanced.Transaction.f.meta.contains('exchange_id')
Expand All @@ -35,42 +78,4 @@ def tearDownClass(cls):
super(BalancedHarness, cls).tearDownClass()


with use_cassette('BalancedHarness'):
cls = BalancedHarness
balanced.configure(balanced.APIKey().save().secret)
mp = balanced.Marketplace.my_marketplace
if not mp:
mp = balanced.Marketplace().save()
cls.balanced_marketplace = mp

cls.david_href = cls.make_balanced_customer()

cls.janet_href = cls.make_balanced_customer()
cls.card = balanced.Card(
number='4111111111111111',
expiration_month=10,
expiration_year=2020,
address={
'line1': "123 Main Street",
'state': 'Confusion',
'postal_code': '90210',
},
# gratipay stores some of the address data in the meta fields,
# continue using them to support backwards compatibility
meta={
'address_2': 'Box 2',
'city_town': '',
'region': 'Confusion',
}
).save()
cls.card.associate_to_customer(cls.janet_href)
cls.card_href = unicode(cls.card.href)

cls.homer_href = cls.make_balanced_customer()
cls.bank_account = balanced.BankAccount(
name='Homer Jay',
account_number='112233a',
routing_number='121042882',
).save()
cls.bank_account.associate_to_customer(cls.homer_href)
cls.bank_account_href = unicode(cls.bank_account.href)

0 comments on commit 40bbf50

Please sign in to comment.