@@ -58,21 +58,26 @@ def test_00_merchant_expectations(self):
58
58
mps = balanced .Marketplace .query .all ()
59
59
self .assertEqual (len (mps ), 1 )
60
60
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
+
61
73
def _find_buyer_account (self ):
62
74
mp = balanced .Marketplace .query .one ()
63
75
accounts = list (mp .accounts )
64
76
filtered_accounts = [
65
77
account for account in accounts if account .roles == ['buyer' ]
66
78
]
67
79
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 ()
76
81
else :
77
82
buyer = filtered_accounts [0 ]
78
83
return buyer
@@ -94,7 +99,7 @@ def test_valid_non_us_address_no_postal_code(self):
94
99
balanced .Card (** card_payload ).save ()
95
100
96
101
def test_valid_us_address (self ):
97
- buyer = self ._find_buyer_account ()
102
+ buyer = self ._create_buyer_account ()
98
103
self .assertTrue (buyer .id .startswith ('AC' ), buyer .id )
99
104
self .assertEqual (buyer .roles , ['buyer' ])
100
105
self .assertDictEqual (buyer .meta , {'foo' : 'bar' })
@@ -233,15 +238,15 @@ def test_transactions_invalid_funding_sources(self):
233
238
the_exception = exc .exception
234
239
self .assertEqual (the_exception .status_code , 409 )
235
240
self .assertEqual (the_exception .category_code ,
236
- 'funding-source-not-valid ' )
241
+ 'bad- funding-info ' )
237
242
238
243
with self .assertRaises (requests .HTTPError ) as exc :
239
244
# ... and explicitly
240
245
buyer .debit (7000 , source_uri = card .uri )
241
246
the_exception = exc .exception
242
247
self .assertEqual (the_exception .status_code , 409 )
243
248
self .assertEqual (the_exception .category_code ,
244
- 'funding-source-not-valid ' )
249
+ 'bad- funding-info ' )
245
250
246
251
with self .assertRaises (requests .HTTPError ) as exc :
247
252
buyer .credit (8000 )
@@ -356,14 +361,14 @@ def test_zzz_remove_owner_merchant_account_bank_account(self):
356
361
owner .debit (600 )
357
362
the_exception = exc .exception
358
363
self .assertEqual (the_exception .status_code , 409 )
359
- self .assertEqual ('funding-source-not-valid ' ,
364
+ self .assertEqual ('bad- funding-info ' ,
360
365
the_exception .category_code )
361
366
362
367
with self .assertRaises (requests .HTTPError ) as exc :
363
368
owner .credit (900 )
364
369
the_exception = exc .exception
365
370
self .assertEqual (the_exception .status_code , 409 )
366
- self .assertEqual ('funding-destination-not-valid ' ,
371
+ self .assertEqual ('bad- funding-info ' ,
367
372
the_exception .category_code )
368
373
369
374
0 commit comments