def test_complete_not_there(self, check): check.return_value = {'status': 'COMPLETED', 'pay_key': 'foo'} Transaction.create(uid_pay='bar', amount=5, uuid=self.uuid, provider=constants.PROVIDER_PAYPAL, seller_product=self.product) res = self.client.post(self.check_url, data={'pay_key': 'foo'}) eq_(res.status_code, 404)
def test_complete_not_there(self, check): check.return_value = {'status': 'COMPLETED', 'pay_key': 'foo'} Transaction.create(uid_pay='bar', amount=5, uuid=self.uuid, provider=constants.SOURCE_PAYPAL, seller_product=self.product) res = self.client.post(self.check_url, data={'pay_key': 'foo'}) eq_(res.status_code, 404)
def test_checked(self, check): check.return_value = {'status': 'COMPLETED', 'pay_key': 'foo'} pp = Transaction.create(uid_pay='foo', amount=5, uuid=self.uuid, provider=constants.SOURCE_PAYPAL, seller_product=self.product) res = self.client.post(self.check_url, data={'pay_key': 'foo'}) eq_(res.status_code, 201) eq_(Transaction.objects.get(pk=pp.pk).status, constants.STATUS_CHECKED)
def test_checked(self, check): check.return_value = {'status': 'COMPLETED', 'pay_key': 'foo'} pp = Transaction.create(uid_pay='foo', amount=5, uuid=self.uuid, provider=constants.PROVIDER_PAYPAL, seller_product=self.product) res = self.client.post(self.check_url, data={'pay_key': 'foo'}) eq_(res.status_code, 201) eq_(Transaction.objects.get(pk=pp.pk).status, constants.STATUS_CHECKED)
def test_timed(self, statsd): trans = Transaction(**self.get_data()) trans.save() ok_(not statsd.timing.called) trans.status = constants.STATUS_COMPLETED trans.save() statsd.timing.assert_called_with('transaction.status.completed', ANY)
def test_uid_pay(self): data = self.get_data() with self.assertRaises(ValidationError): Transaction.create(**data) # No uid_pay. data['uid_pay'] = 'abc' Transaction.create(**data) eq_(Transaction.objects.count(), 1) data['uuid'] = data['uuid'] + ':foo' with self.assertRaises(ValidationError): Transaction.create(**data) # Uid pay conflicts. data['provider'] = constants.SOURCE_PAYPAL Transaction.create(**data) eq_(Transaction.objects.count(), 2)
def test_complete(self, check): check.return_value = {'status': 'COMPLETED', 'pay_key': 'foo'} pp = Transaction.create(uid_pay='foo', amount=5, uuid=self.uuid, provider=constants.PROVIDER_PAYPAL, seller_product=self.product) self.client.post(self.check_url, data={'pay_key': 'foo'}) eq_(Transaction.objects.get(pk=pp.pk).status, constants.STATUS_CHECKED) pp.status = constants.STATUS_COMPLETED pp.save() self.client.post(self.check_url, data={'pay_key': 'foo'}) eq_(Transaction.objects.get(pk=pp.pk).status, constants.STATUS_COMPLETED)
def test_uid_pay(self): data = self.get_data() data['uid_pay'] = 'abc' Transaction.create(**data) eq_(Transaction.objects.count(), 1) data['uuid'] = data['uuid'] + ':foo' with self.assertRaises(ValidationError): Transaction.create(**data) # Uid pay conflicts. data['provider'] = constants.PROVIDER_REFERENCE Transaction.create(**data) eq_(Transaction.objects.count(), 2)
def add_related(self): original = Transaction.create(**self.get_data()) related = Transaction.create(related=original, **self.get_data(uid='foo')) return original, related