예제 #1
0
 def test_customer_200(self):
     """If a basket is not empty then the checkout reponds with 200"""
     request = self.rf.get(reverse('cccheckout:customer'))
     request.session['cccheckout'] = self.checkout
     request.session.save()
     response = customer(request)
     request = self.rf.get(reverse('cccheckout:customer'))
     request.session['cccheckout'] = self.checkout
     request.session.save()
     response = customer(request)
     self.assertEqual(200, response.status_code)
예제 #2
0
 def test_customer_get_200(self):
     """when customer is called via get we have a 200"""
     request = self.rf.get(reverse('cccheckout:customer'))
     request.session['cccheckout'] = self.checkout
     request.session.save()
     response = customer(request)
     self.assertEqual(200, response.status_code)
예제 #3
0
 def test_customer_post_200(self):
     """post incorrect data and we get a 200"""
     request = self.rf.post(reverse('cccheckout:customer'), {})
     request.session['cccheckout'] = self.checkout
     request.session.save()
     response = customer(request)
     self.assertEqual(200, response.status_code)
예제 #4
0
 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)
예제 #5
0
 def test_customer_redirects_to_postage(self):
     """Any attempt to acccess the customer view redirects to the 
     postage view"""
     request = self.rf.get(reverse('cccheckout:customer'))
     request.session['cccheckout'] = self.checkout
     r = customer(request)
     self.assertEqual(302, r.status_code)
     self.assertEqual(r['Location'], reverse('cccheckout:postage'))
예제 #6
0
 def test_no_form_bypasses_customer(self):
     """if `CCCHECKOUT_CUSTOMER_FORM` is None then the customer is not
     required"""
     settings.CCCHECKOUT_CUSTOMER_FORM = None
     reload(c_settings)
     # hit the customer view and it should be a 302
     request = self.rf.get('/')
     request.session['cccheckout'] = self.checkout
     request.session.save()
     response = customer(request)
     self.assertEqual(302, response.status_code)
예제 #7
0
 def test_is_true_start(self):
     """  
     if CCCHECKOUT_ALLOW_GUEST == `True`: 
         checkout flow proceeds without a redirect to settings.LOGIN_URL
     """
     request = self.rf.get(reverse('cccheckout:customer'))
     request.session['cccheckout'] = self.checkout
     request.session.save()
     # start
     response = customer(request)
     self.assertEqual(200, response.status_code)
 def test_monetary_based_discount(self):
     """monetary based discounts behave correctly"""
     d = DiscountCode()
     d.title = 'test discount code'
     d.code = 'TEST'
     d.type = DiscountCode.MONETARY
     d.discount = Decimal('2.00')
     d.save()
     # make the request
     #settings.CCCHECKOUT_ADAPTER = 'cccheckout.tests.mock.testcase_adapter'
     post_request = self.rf.post('/yeah', {'code': 'TEST'})
     self.request = post_request
     self.request.session['cccheckout'] = self.checkout
     self.request.session.save()
     # get start page ad checkout total is now 9.00
     response = customer(self.request)
     self.assertEqual(self.request.session['cccheckout'].total_price(),
                     Decimal('8.00'))
    def test_percentage_based_discount(self):
        """percentage based discounts behave correctly"""
        d = DiscountCode()
        d.title = 'test discount code'
        d.code = 'TEST'
        d.type = DiscountCode.PERCENTAGE
        d.discount = 10
        d.save()
        # make the request

        post_request = self.rf.post('/yeah', {'code': 'TEST'})
        self.request = post_request
        self.request.session['cccheckout'] = self.checkout
        self.request.session.save()
        # get start page abd checkout total is now 9.00
        response = customer(self.request)
        self.assertEqual(self.request.session['cccheckout'].total_price(),
                        Decimal('9.00'))
예제 #10
0
 def test_customer_post_302(self):
     """send valid post information and we get a 302"""
     data = {
         'name': 'Testy Tester',
         'email': '*****@*****.**',
         'phone': '+0044-123123',
         'delivery_address_1': 'Somewhere',
         'delivery_city': 'Some City',
         'delivery_postcode': 'NE12 8UJ',
         'delivery_country': 'GB',
         'billing_address_1': 'Somewhere',
         'billing_city': 'Some City',
         'billing_postcode': 'NE12 8UJ',
         'billing_country': 'GB',
     }
     request = self.rf.post(reverse('cccheckout:customer'), data)
     request.session['cccheckout'] = self.checkout
     request.session.save()
     response = customer(request)
     self.assertEqual(302, response.status_code)
예제 #11
0
 def test_customer_model_saved_to_checkout(self):
     data = {
         'name': 'Testy Tester',
         'email': '*****@*****.**',
         'phone': '+0044-123123',
         'delivery_address_1': 'Somewhere',
         'delivery_city': 'Some City',
         'delivery_postcode': 'NE12 8UJ',
         'delivery_country': 'GB',
         'billing_address_1': 'Somewhere',
         'billing_city': 'Some City',
         'billing_postcode': 'NE12 8UJ',
         'billing_country': 'GB',
     }
     # no customer
     self.assertFalse(self.checkout.customer)
     request = self.rf.post(reverse('cccheckout:customer'), data)
     request.session['cccheckout'] = self.checkout
     request.session.save()
     response = customer(request)
     self.assertEqual(302, response.status_code)
     self.assertTrue(self.checkout.customer)
예제 #12
0
 def test_customer_is_200(self):
     """customer responds with a 200 ok"""
     request = self.rf.get(reverse('cccheckout:customer'))
     request.session['cccheckout'] = self.checkout
     r = customer(request)
     self.assertEqual(200, r.status_code)
예제 #13
0
 def test_customer_redirects_empty(self):
     """If a basket is empty then the checkout redirects to the basket"""
     request = self.rf.get(reverse('cccheckout:customer'))
     response = customer(request)
     self.assertEqual(302, response.status_code)