8000 tests for associating bad cards · balanced/balanced-python@0cc01d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cc01d8

Browse files
author
Marc Sherry
committed
tests for associating bad cards
1 parent 781c359 commit 0cc01d8

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

tests/acceptance_suite.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_create_simple_credit(self):
117117

118118
def test_credit_lower_than_escrow(self):
119119
mp = balanced.Marketplace.query.one()
120-
escrow_balance = mp.in_escrow
120+
escrow_balance = mp.in_escrow
121121
credit_amount = escrow_balance + 10000
122122
merchants = mp.accounts
123123
merchant = merchants[0]
@@ -132,6 +132,50 @@ def test_valid_international_address(self):
132132
self.assertEqual(card.street_address,
133133
card_payload['street_address'])
134134

135+
def test_associate_bad_cards(self):
136+
mp = balanced.Marketplace.query.one()
137+
card_payload = dict(self.us_card_payload)
138+
card = balanced.Card(**card_payload).save()
139+
card_uri = card.uri
140+
buyer = mp.create_buyer(
141+
email_address='james@watson.com',
142+
card_uri=card_uri,
143+
meta={'foo': 'bar'},
144+
)
145+
# Invalid card
146+
card_payload = dict(self.us_card_payload)
147+
card_payload['is_valid'] = False
148+
card = balanced.Card(**card_payload).save()
149+
card_uri = card.uri
150+
with self.assertRaises(requests.HTTPError) as exc:
151+
buyer.add_card(card_uri=card_uri)
152+
the_exception = exc.exception
153+
self.assertEqual(the_exception.status_code, 409)
154+
self.assertEqual(the_exception.category_code,
155+
'funding-source-not-valid')
156+
157+
# Already-associated card
158+
card_payload = dict(self.us_card_payload)
159+
card = balanced.Card(**card_payload).save()
160+
card_uri = card.uri
161+
mp.create_buyer(
162+
email_address='james@moriarty.com',
163+
card_uri=card_uri,
164+
meta={'foo': 'bar'},
165+
)
166+
with self.assertRaises(requests.HTTPError) as exc:
167+
buyer.add_card(card_uri=card_uri)
168+
the_exception = exc.exception
169+
self.assertEqual(the_exception.status_code, 409)
170+
self.assertEqual(the_exception.category_code,
171+
'card-already-funding-src')
172+
173+
# Completely fake card uri
174+
with self.assertRaises(requests.HTTPError) as exc:
175+
buyer.add_card(card_uri='/completely/fake')
176+
the_exception = exc.exception
177+
self.assertEqual(the_exception.status_code, 400)
178+
135179
def test_transactions_invalid_funding_sources(self):
136180< 3FA4 /code>
mp = balanced.Marketplace.query.one()
137181
card_payload = dict(self.us_card_payload)

0 commit comments

Comments
 (0)
0