Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
    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)
Example #6
0
    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)
Example #7
0
    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)
Example #9
0
    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)
Example #10
0
 def add_related(self):
     original = Transaction.create(**self.get_data())
     related = Transaction.create(related=original,
                                  **self.get_data(uid='foo'))
     return original, related
Example #11
0
 def add_related(self):
     original = Transaction.create(**self.get_data())
     related = Transaction.create(related=original,
                                  **self.get_data(uid='foo'))
     return original, related