def test_reversal(self, reversal, post): post.return_value.text = 'VERIFIED' post.return_value.status_code = 200 reversal.return_value = True ipn = IPN(urllib.urlencode(samples.sample_reversal)) ipn.process() eq_(ipn.status, constants.IPN_STATUS_OK)
def test_chained_refund(self, refunded, post): post.return_value.text = 'VERIFIED' refunded.return_value = True ipn = IPN(urllib.urlencode(samples.sample_chained_refund)) ipn.process() eq_(refunded.call_count, 1) eq_(ipn.status, constants.IPN_STATUS_OK)
def test_purchase(self, completed, post): post.return_value.text = 'VERIFIED' post.return_value.status_code = 200 completed.return_value = True ipn = IPN(urllib.urlencode(samples.sample_purchase)) ipn.process() eq_(ipn.status, constants.IPN_STATUS_OK)
def test_purchase_not(self, completed, post): post.return_value.text = 'VERIFIED' post.return_value.status_code = 200 completed.return_value = False ipn = IPN(urllib.urlencode(samples.sample_purchase)) ipn.process() eq_(ipn.status, constants.IPN_STATUS_IGNORED)
def test_chained_refund(self, refunded, post): post.return_value.text = 'VERIFIED' post.return_value.status_code = 200 refunded.return_value = True ipn = IPN(urllib.urlencode(samples.sample_chained_refund)) ipn.process() eq_(refunded.call_count, 1) eq_(ipn.status, constants.IPN_STATUS_OK)
def obj_create(self, bundle, request, **kwargs): form = IPNForm(bundle.data) if not form.is_valid(): raise self.form_errors(form) ipn = IPN(form.cleaned_data['data']) ipn.process() bundle.ipn = ipn return bundle
def test_calls(self, post): post.return_value.text = 'VERIFIED' post.return_value.status_code = 200 eq_(IPN('status=completed').is_valid(), True)
def create(self, data): ipn = IPN(data) mock = Mock() mock.return_value = True ipn.is_valid = mock return ipn
def test_not_completed(self, post): eq_(IPN('status=something').is_valid(), False)
def test_not_valid(self, post): post.return_value.text = 'NOPE' post.return_value.status_code = 200 eq_(IPN('status=completed').is_valid(), False)
def test_empty(self, post): eq_(IPN('').is_valid(), False)
def test_invalid(self, post): ipn = IPN('') ipn.process() eq_(ipn.status, constants.IPN_STATUS_IGNORED)
def test_still_ignored(self, post): post.return_value.text = 'VERIFIED' post.return_value.status_code = 200 ipn = IPN(urllib.urlencode(samples.sample_refund)) ipn.process() eq_(ipn.status, constants.IPN_STATUS_IGNORED)
def test_purchase_not(self, completed, post): post.return_value.text = 'VERIFIED' completed.return_value = False ipn = IPN(urllib.urlencode(samples.sample_purchase)) ipn.process() eq_(ipn.status, constants.IPN_STATUS_IGNORED)