Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
Added test for CV2AVS
Browse files Browse the repository at this point in the history
  • Loading branch information
codeinthehole committed Dec 26, 2011
1 parent 7ba151c commit 71c2158
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Datacash package for django-oscar
Installation
------------

From PyPi::
From PyPi (not ready just yet)::

pip install django-oscar-datacash

Expand All @@ -29,3 +29,5 @@ Settings
* ``DATACASH_PASSWORD`` - Password

* ``DATACASH_CURRENCY`` - Currency to use for transactions

* ``DATACASH_USE_CV2AVS`` - Whether to pass CV2AVS data
7 changes: 4 additions & 3 deletions datacash/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ class Facade(object):
"""

def __init__(self):
self.gateway = Gateway(settings.DATACASH_CLIENT,
settings.DATACASH_PASSWORD,
settings.DATACASH_HOST)
self.gateway = Gateway(settings.DATACASH_HOST,
settings.DATACASH_CLIENT,
settings.DATACASH_PASSWORD,
settings.DATACASH_USE_CV2AVS)
self.currency = settings.DATACASH_CURRENCY

def pre_auth(self):
Expand Down
32 changes: 31 additions & 1 deletion datacash/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
</Response>"""


class FacadeTests(TestCase):
pass


class TransactionModelTests(TestCase):

def test_cc_numbers_are_not_saved_in_xml(self):
Expand All @@ -70,7 +74,33 @@ def test_cc_numbers_are_not_saved_in_xml(self):
self.assertEqual('XXXXXXXXXXXX0004', element.firstChild.data)


class GatewayMockTests(TestCase):
class GatewayWithCV2AVSMockTests(TestCase):

def setUp(self):
self.gateway = Gateway('example.com', 'dummyclient', 'dummypassword', True)

def gateway_auth(self, amount=D('1000.00'), currency='GBP', card_number='1000350000000007',
expiry_date='10/12', merchant_reference='TEST_132473839018', response_xml=SAMPLE_RESPONSE, **kwargs):
self.gateway._fetch_response_xml = Mock(return_value=response_xml)
response = self.gateway.auth(amount=amount,
currency=currency,
card_number=card_number,
expiry_date=expiry_date,
merchant_reference=merchant_reference,
**kwargs)
return response

def test_ccv_is_included_in_request(self):
response = self.gateway_auth(ccv='456')

doc = parseString(response.request_xml)
card_element = doc.getElementsByTagName('Card')[0]
cv2avs_element = card_element.getElementsByTagName('Cv2Avs')[0]
cv2_element = cv2avs_element.getElementsByTagName('cv2')[0]
self.assertEqual('456', cv2_element.firstChild.data)


class GatewayWithoutCV2AVSMockTests(TestCase):

def setUp(self):
self.gateway = Gateway('example.com', 'dummyclient', 'dummypassword')
Expand Down

0 comments on commit 71c2158

Please sign in to comment.