Example #1
0
 def test_dummy_form_save_credit_number(self):
     """
     Test that dummy payment form save method save order
     """
     wizard = PrePaymentWizard()
     cart = model_factory(Cart, save=True)
     wizard.order = model_factory(Order, cart=cart)
     form = DummyPaymentForm()
     form.cleaned_data = FORM_CLEANED_DATA
     order = form.save(wizard)
     self.assertEqual(order.card_number, '1111')
Example #2
0
 def test_trustcommerce_form_save_credit_number(self):
     """
     Test that method save last four number or credit cart
     """
     wizard = PrePaymentWizard()
     request = RequestFactory().get('/')
     request.session = {}
     wizard.request = request
     cart = model_factory(Cart, save=True)
     wizard.order = model_factory(Order, cart=cart)
     form = TrustCommercePaymentForm()
     form.cleaned_data = FORM_CLEANED_DATA
     order = form.save(wizard)
     self.assertEqual(order.card_number, '1111')
Example #3
0
 def test_trustcommerce_form_save_session(self):
     """
     Test that method set data in session
     """
     expected_dict = PAYMENT_INFO_IN_SESSION.copy()
     wizard = PrePaymentWizard()
     request = RequestFactory().get('/')
     request.session = {}
     wizard.request = request
     cart = model_factory(Cart, save=True)
     wizard.order = model_factory(Order, cart=cart, save=True)
     form = TrustCommercePaymentForm()
     form.cleaned_data = FORM_CLEANED_DATA
     form.save(wizard)
     self.assertEqual(expected_dict, request.session)
Example #4
0
    def test_save(self):
        """
        Test that method set currect data to order
        """
        expected_list = ['flat', 20.0]

        cart = model_factory(Cart, save=True)
        order = model_factory(Order, cart=cart, save=True)
        request = RequestFactory()
        request.session = {'shipping_cost': 20}

        wizard = PrePaymentWizard()
        wizard.order = order
        wizard.request = request

        form = ChoiceShippingForm()
        form.cleaned_data = {'shipping_method': 'flat'}
        form.save(wizard)
        self.assertEqual(expected_list, [wizard.order.shipping_method,
                                         wizard.order.shipping_price])