def test_bad_form(self):
        params = self.post_params.copy()
        params['md5'] = CheckOrderForm.make_md5(params)

        count = randint(1, 5)
        item = self.get_item()
        payment = Payment.objects.create(shop_id=params['shopId'],
                                         customer_number=params['customerNumber'],
                                         invoice_id=params['invoiceId'],
                                         order_amount=params['orderSumAmount'],
                                         order_currency=params['orderSumCurrencyPaycash'],
                                         payment_type=params['paymentType'])
        Order.objects.create(item=item, count=count,
                             amount=int(params['orderSumAmount']), payment=payment)

        del params['orderSumAmount']  # Made form data as wrong
        res = self.app.post(self.url, params=params)

        self.assertEquals(res.status_code, 200, 'HTTP code is not 200')

        body = '<?xml version="1.0" encoding="UTF-8"?>\n<checkOrderResponse code="200" />'
        self.assertEqual(body, res.body, 'Body is not contains code="200"')

        payment = Payment.objects.get(pk=payment.pk)
        self.assertEquals(payment.status, Payment.STATUS.FAIL, 'Status is not set to "FAIL"')
        self.assertIsNone(payment.shop_amount, 'Shop amount was set for wrond form data')
        self.assertIsNone(payment.performed_datetime, 'Performed time was set for wrond form data')
Ejemplo n.º 2
0
    def test_check_order(self):
        params = self.post_params.copy()
        params['md5'] = CheckOrderForm.make_md5(params)

        count = randint(1, 5)
        item = self.get_item()
        payment = Payment.objects.create(
            shop_id=params['shopId'],
            customer_number=params['customerNumber'],
            invoice_id=params['invoiceId'],
            order_amount=params['orderSumAmount'],
            order_currency=params['orderSumCurrencyPaycash'],
            payment_type=params['paymentType'])
        Order.objects.create(item=item,
                             count=count,
                             amount=int(params['orderSumAmount']),
                             payment=payment)

        res = self.app.post(self.url, params=params)
        self.assertEquals(res.status_code, 200, 'HTTP code is not 200')

        payment = Payment.objects.get(pk=payment.pk)
        self.assertEquals(payment.status, Payment.STATUS.PROCESSED,
                          'Status is not set to "PROCESSED"')
        self.assertEquals(float(payment.shop_amount), params['shopSumAmount'],
                          'Shop amount was not changed')
        self.assertIsNotNone(payment.performed_datetime,
                             'Performed time was not set')
    def test_payment_aviso(self):
        params = self.post_params.copy()
        params['md5'] = CheckOrderForm.make_md5(params)

        count = randint(1, 5)
        item = self.get_item()
        payment = Payment.objects.create(shop_id=params['shopId'],
                                         customer_number=params['customerNumber'],
                                         invoice_id=params['invoiceId'],
                                         order_amount=params['orderSumAmount'],
                                         order_currency=params['orderSumCurrencyPaycash'],
                                         payment_type=params['paymentType'])
        Order.objects.create(item=item, count=count,
                             amount=int(params['orderSumAmount']), payment=payment)

        res = self.app.post(self.url, params=params)
        self.assertEquals(res.status_code, 200, 'HTTP code is not 200')

        payment = Payment.objects.get(pk=payment.pk)
        self.assertEquals(payment.status, Payment.STATUS.SUCCESS, 'Status is not set to "SUCCESS"')
    def test_check_order(self):
        params = self.post_params.copy()
        params['md5'] = CheckOrderForm.make_md5(params)

        count = randint(1, 5)
        item = self.get_item()
        payment = Payment.objects.create(shop_id=params['shopId'],
                                         customer_number=params['customerNumber'],
                                         invoice_id=params['invoiceId'],
                                         order_amount=params['orderSumAmount'],
                                         order_currency=params['orderSumCurrencyPaycash'],
                                         payment_type=params['paymentType'])
        Order.objects.create(item=item, count=count,
                             amount=int(params['orderSumAmount']), payment=payment)

        res = self.app.post(self.url, params=params)
        self.assertEquals(res.status_code, 200, 'HTTP code is not 200')

        payment = Payment.objects.get(pk=payment.pk)
        self.assertEquals(payment.status, Payment.STATUS.PROCESSED, 'Status is not set to "PROCESSED"')
        self.assertEquals(float(payment.shop_amount), params['shopSumAmount'], 'Shop amount was not changed')
        self.assertIsNotNone(payment.performed_datetime, 'Performed time was not set')