def setUp(self):
        if None in [SANDBOX_CLIENT_KEY, SANDBOX_SERVER_KEY]:
            self.skipTest("Live credentials not provided -- skipping tests")
        if not RUN_ALL_ACCEPTANCE_TESTS and \
                self.VERSION != veritranspay.__version__:
            self.skipTest("Skipping this version of tests")

        expected = fixtures.CC_REQUEST
        self.expected = expected

        self.trans_details = request.TransactionDetails(
            order_id="".join([fake.random_letter() for _ in range(10)]),
            gross_amount=expected['transaction_details']['gross_amount'])

        self.cust_details = request.CustomerDetails(
            first_name=expected['customer_details']['first_name'],
            last_name=expected['customer_details']['last_name'],
            email=expected['customer_details']['email'],
            phone=expected['customer_details']['phone'],
            billing_address=request.Address(
                **expected['customer_details']['billing_address']),
            shipping_address=request.Address(
                **expected['customer_details']['shipping_address'])
            )

        self.item_details = \
            [request.ItemDetails(item_id=item['id'],
                                 price=item['price'],
                                 quantity=item['quantity'],
                                 name=item['name'])
             for item
             in expected['item_details']]
Exemple #2
0
    def setUp(self):
        if None in [SANDBOX_CLIENT_KEY, SANDBOX_SERVER_KEY]:
            self.skipTest("Live credentials not provided -- skipping tests")

        if not RUN_ALL_ACCEPTANCE_TESTS and \
                self.VERSION != veritranspay.__version__:
            self.skipTest("Skipping %s this version of tests" % self.VERSION)

        expected = fixtures.GOPAY_REQUEST
        self.expected = expected

        self.trans_details = request.TransactionDetails(
            order_id=expected['transaction_details']['order_id'],
            gross_amount=expected['transaction_details']['gross_amount'])

        self.cust_details = request.CustomerDetails(
            first_name=expected['customer_details']['first_name'],
            last_name=expected['customer_details']['last_name'],
            email=expected['customer_details']['email'],
            phone=expected['customer_details']['phone'],
        )
        self.item_details = \
            [request.ItemDetails(item_id=item['id'],
                                 price=item['price'],
                                 quantity=item['quantity'],
                                 name=item['name'])
             for item
             in expected['item_details']]
    def test_serialization(self):
        '''
        This test covers the serialization of ChargeRequest and all of it's
        subentities.
        '''
        expected = fixtures.CC_REQUEST

        cc_payment = payment_types.CreditCard(
            bank=expected['credit_card']['bank'],
            token_id=expected['credit_card']['token_id'],
            bins=expected['credit_card']['bins'])
        trans_details = request.TransactionDetails(
            order_id=expected['transaction_details']['order_id'],
            gross_amount=expected['transaction_details']['gross_amount'])
        cust_details = request.CustomerDetails(
            first_name=expected['customer_details']['first_name'],
            last_name=expected['customer_details']['last_name'],
            email=expected['customer_details']['email'],
            phone=expected['customer_details']['phone'],
            billing_address=request.Address(
                **expected['customer_details']['billing_address']),
            shipping_address=request.Address(
                **expected['customer_details']['shipping_address'])
            )
        item_details = [request.ItemDetails(item_id=item['id'],
                                            price=item['price'],
                                            quantity=item['quantity'],
                                            name=item['name'])
                        for item
                        in expected['item_details']]

        charge_req = request.ChargeRequest(charge_type=cc_payment,
                                           transaction_details=trans_details,
                                           customer_details=cust_details,
                                           item_details=item_details)

        actual = charge_req.serialize()

        self.assertEqual(actual, expected)