示例#1
0
 def test_customer_redirects_to_payment(self):
     """Because there is no postage required, any attempt to access
     postage redirects to the payment page"""
     # no customer the postage redirects and so does the payment
     request = self.rf.get(reverse('cccheckout:postage'))
     request.session['cccheckout'] = self.checkout
     r = postage(request)
     self.assertEqual(302, r.status_code)
     # payment redirects
     request = self.rf.get(reverse('cccheckout:payment'))
     request.session['cccheckout'] = self.checkout
     r = payment(request)
     self.assertEqual(302, r.status_code)
     # add a customer and it is now only postage redirects
     self.checkout.customer = Customer()
     self.checkout.customer.save()
     self.checkout.save()
     # get the views again and postage is still 302
     request = self.rf.get(reverse('cccheckout:postage'))
     request.session['cccheckout'] = self.checkout
     r = postage(request)
     self.assertEqual(302, r.status_code)
     # payment redirects
     request = self.rf.get(reverse('cccheckout:payment'))
     request.session['cccheckout'] = self.checkout
     r = payment(request)
     self.assertEqual(200, r.status_code)
 def test_is_false(self):
     """  
     if CCCHECKOUT_ALLOW_GUEST == `True`: 
         checkout flow proceeds without a redirect to settings.LOGIN_URL
     """
     # set to False
     settings.CCCHECKOUT_ALLOW_GUEST = False
     # customer
     request = self.rf.get(reverse('cccheckout:customer'))
     request.session['cccheckout'] = self.checkout
     request.session.save()
     response = customer(request)
     self.assertEqual(302, response.status_code)
     # postage
     request = self.rf.get(reverse('cccheckout:postage'))
     request.session['cccheckout'] = self.checkout
     request.session.save()
     response = postage(request)
     self.assertEqual(302, response.status_code)
     # payment
     request = self.rf.get(reverse('cccheckout:payment'))
     request.session['cccheckout'] = self.checkout
     request.session.save()
     response = payment(request)
     self.assertEqual(302, response.status_code)
示例#3
0
 def test_if_postage_required_and_has_none_then_payment_redirects(self):
     """if a checkout has no postage and postage is required then payment
     redirects to the postage page"""
     # no customer the postage redirects and so does the payment
     request = self.rf.get(reverse('cccheckout:payment'))
     request.session['cccheckout'] = self.checkout
     r = payment(request)
     self.assertEqual(302, r.status_code)
     self.assertEqual(r['Location'], reverse('cccheckout:postage'))
示例#4
0
 def test_payment_200(self):
     """If a basket is not empty then the checkout reponds with 200"""
     request = self.rf.get(reverse('cccheckout:payment'))
     request.session['cccheckout'] = self.checkout
     # add a customer
     self.checkout.customer = Customer()
     self.checkout.customer.save()
     # add postage
     postage = Line(name='test')
     postage.save()
     tier = LineTier(minimum=1,
             maximum=2,
             price=Decimal('2.00'),
             line=postage)
     tier.save()
     country = LineCountry(country='GB', line=postage)
     country.save()
     self.checkout.postage = postage
     self.checkout.postage_tier = tier
     request.session.save()
     response = payment(request)
     self.assertEqual(200, response.status_code)
示例#5
0
 def test_payment_responds_with_postage(self):
     """If there is postage then payment responds 200"""
     p = Line()
     p.name = 'test'
     p.save()
     p_tier = LineTier()
     p_tier.line = p
     p_tier.minimum = Decimal('0.00')
     p_tier.maximum = Decimal('0.00')
     p_tier.price = Decimal('2.00')
     p_tier.save()
     p_country = LineCountry()
     p_country.line = p
     p_country.country = 'GB'
     p_country.save()
     checkout = deepcopy(self.checkout)
     checkout.postage = p
     checkout.postage_tier = p_tier
     checkout.save()
     # process and all is fine
     request = self.rf.get(reverse('cccheckout:payment'))
     request.session['cccheckout'] = checkout
     r = payment(request)
     self.assertEqual(200, r.status_code)
示例#6
0
 def test_payment_redirects_empty(self):
     """If a basket is empty then the checkout redirects to the basket"""
     request = self.rf.get(reverse('cccheckout:payment'))
     response = payment(request)
     self.assertEqual(302, response.status_code)