8000 fix acceptance tests · balanced/balanced-python@fb14ff2 · GitHub
[go: up one dir, main page]

Skip to content

Commit fb14ff2

Browse files
author
Marc Sherry
committed
fix acceptance tests
1 parent 472503f commit fb14ff2

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

‎tests/acceptance_suite.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,26 @@ def test_00_merchant_expectations(self):
5858
mps = balanced.Marketplace.query.all()
5959
self.assertEqual(len(mps), 1)
6060

61+
def _create_buyer_account(self):
62+
mp = balanced.Marketplace.query.one()
63+
card_payload = dict(self.us_card_payload)
64+
card = balanced.Card(**card_payload).save()
65+
card_uri = card.uri
66+
buyer = mp.create_buyer(
67+
email_address='albert@einstein.com',
68+
card_uri=card_uri,
69+
meta={'foo': 'bar'},
70+
)
71+
return buyer
72+
6173
def _find_buyer_account(self):
6274
mp = balanced.Marketplace.query.one()
6375
accounts = list(mp.accounts)
6476
filtered_accounts = [
6577
account for account in accounts if account.roles == ['buyer']
6678
]
6779
if not filtered_accounts:
68-
card_payload = dict(self.us_card_payload)
69-
card = balanced.Card(**card_payload).save()
70-
card_uri = card.uri
71-
buyer = mp.create_buyer(
72-
email_address='albert@einstein.com',
73-
card_uri=card_uri,
74-
meta={'foo': 'bar'},
75-
)
80+
buyer = self._create_buyer_account()
7681
else:
7782
buyer = filtered_accounts[0]
7883
return buyer
@@ -94,7 +99,7 @@ def test_valid_non_us_address_no_postal_code(self):
9499
balanced.Card(**card_payload).save()
95100

96101
def test_valid_us_address(self):
97-
buyer = self._find_buyer_account()
102+
buyer = self._create_buyer_account()
98103
self.assertTrue(buyer.id.startswith('AC'), buyer.id)
99104
self.assertEqual(buyer.roles, ['buyer'])
100105
self.assertDictEqual(buyer.meta, {'foo': 'bar'})
@@ -233,15 +238,15 @@ def test_transactions_invalid_funding_sources(self):
233238
the_exception = exc.exception
234239
self.assertEqual(the_exception.status_code, 409)
235240
self.assertEqual(the_exception.category_code,
236-
'funding-source-not-valid')
241+
'bad-funding-info')
237242

238243
with self.assertRaises(requests.HTTPError) as exc:
239244
# ... and explicitly
240245
buyer.debit(7000, source_uri=card.uri)
241246
the_exception = exc.exception
242247
self.assertEqual(the_exception.status_code, 409)
243248
self.assertEqual(the_exception.category_code,
244-
'funding-source-not-valid')
249+
'bad-funding-info')
245250

246251
with self.assertRaises(requests.HTTPError) as exc:
247252
buyer.credit(8000)
@@ -356,14 +361,14 @@ def test_zzz_remove_owner_merchant_account_bank_account(self):
356361
owner.debit(600)
357362
the_exception = exc.exception
358363
self.assertEqual(the_exception.status_code, 409)
359-
self.assertEqual('funding-source-not-valid',
364+
self.assertEqual('bad-funding-info',
360365
the_exception.category_code)
361366

362367
with self.assertRaises(requests.HTTPError) as exc:
363368
owner.credit(900)
364369
the_exception = exc.exception
365370
self.assertEqual(the_exception.status_code, 409)
366-
self.assertEqual('funding-destination-not-valid',
371+
self.assertEqual('bad-funding-info',
367372
the_exception.category_code)
368373

369374

0 commit comments

Comments
 (0)
0