8000 Fake cards · balanced/balanced-python@0b95130 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b95130

Browse files
author
Ganesh Venkataraman
committed
Fake cards
1 parent 7dfcb80 commit 0b95130

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

tests/acceptance_suite.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ def _find_buyer_account(self):
7979
if not filtered_accounts:
8080
buyer = self._create_buyer_account()
8181
else:
82-
buyer = filtered_accounts[0]
82+
for account in filtered_accounts:
83+
# this account will fail any debit, so don't use it
84+
if account.email_address == 'stephen@hawking.com':
85+
continue
86+
buyer = account
8387
return buyer
8488

8589
def test_merchant_expectations(self):
@@ -149,6 +153,23 @@ def test_valid_international_address(self):
149153
self.assertEqual(card.street_address,
150154
card_payload['street_address'])
151155

156+
def test_bad_card(self):
157+
mp = balanced.Marketplace.query.one()
158+
card_payload = dict(self.us_card_payload)
159+
card_payload['card_number'] = cards.AUTH_INVALID_CARD
160+
bad_card = balanced.Card(**card_payload).save()
161+
bad_card_uri = bad_card.uri
162+
buyer = mp.create_buyer(
163+
email_address='stephen@hawking.com',
164+
card_uri=bad_card_uri,
165+
meta={'foo': 'bar'},
166+
)
167+
with self.assertRaises(requests.HTTPError) as exc:
168+
buyer.debit(777)
169+
the_exception = exc.exception
170+
self.assertEqual(the_exception.status_code, 402)
171+
self.assertEqual(the_exception.category_code, 'card-declined')
172+
152173
def test_transactions_using_second_card(self):
153174
mp = balanced.Marketplace.query.one()
154175
card_payload = dict(self.us_card_payload)

tests/fixtures/cards.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4+
AUTH_INVALID_CARD = '4444444444444448'
5+
6+
VERIFY_FAILED_CARD_NUMBER = '4222222222222220'
47

58
TEST_CARDS = {
69
'visa': [

0 commit comments

Comments
 (0)
0