예제 #1
0
    def setUp(self):
        """Create a basket with things in it
        """
        request = RequestFactory().get('/')
        request.session = {}
        self.bid = bid = basket_id(request)
        self.item = BasketItemFactory(basket_id=bid)
        BasketItemFactory(basket_id=bid)

        self.address = address = AddressFactory()

        self.rate1 = ShippingRate.objects.create(
            name='98d17c43-7e20-42bd-b603-a4c83c829c5a',
            rate=99,
            carrier='8717ca67-4691-4dff-96ec-c43cccd15241',
            description='313037e1-644a-4570-808a-f9ba82ecfb34',
            basket_id=bid,
        )

        self.rate2 = ShippingRate.objects.create(
            name='8e721550-594c-482b-b512-54dc1744dff8',
            rate=97,
            carrier='4f4cca35-1a7a-47ec-ab38-a9918e0c04af',
            description='eacb446d-eb17-4ea7-82c1-ac2f62a53a7d',
            basket_id=bid,
            destination=address,
        )

        self.rate3 = ShippingRate.objects.create(
            name='72991859-dc0b-463e-821a-bf8b04aaed2c',
            rate=95,
            carrier='0aa3c318-b045-4a96-a456-69b4cc71d46a',
            description='78b03c47-b20f-4f91-8161-47340367fb34',
            destination=address,
        )
예제 #2
0
파일: tests.py 프로젝트: xtelaur/longclaw
 def test_create_order(self):
     BasketItemFactory(basket_id=self.basket_id),
     BasketItemFactory(basket_id=self.basket_id)
     order = create_order(self.email, self.request, self.addresses)
     self.assertIsNotNone(order)
     self.assertEqual(self.email, order.email)
     self.assertEqual(order.items.count(), 2)
예제 #3
0
 def test_checkout(self):
     """
     Test api endpoint checkout/
     """
     BasketItemFactory(basket_id=self.basket_id)
     BasketItemFactory(basket_id=self.basket_id)
     data = {'address': self.addresses, 'email': self.email}
     self.post_test(data, 'longclaw_checkout', format='json')
예제 #4
0
 def setUp(self):
     """Create a basket with things in it
     """
     request = RequestFactory().get('/')
     request.session = {}
     bid = basket_id(request)
     self.item = BasketItemFactory(basket_id=bid)
     BasketItemFactory(basket_id=bid)
예제 #5
0
    def setUp(self):
        self.country = CountryFactory()
        self.country2 = CountryFactory()
        self.address = AddressFactory()
        self.address2 = AddressFactory()
        self.address2.country = self.country2
        self.address2.save()

        self.assertNotEqual(self.country.pk, self.country2.pk,
                            'Try again. Random got you!')

        request = RequestFactory().get('/')
        request.session = {}

        self.basket_id = 'bar'
        BasketItemFactory(basket_id=self.basket_id)
        BasketItemFactory(basket_id=self.basket_id)

        self.rate1 = ShippingRate.objects.create(
            name='rate1',
            rate=99,
            carrier='rate1c',
            description='rate1d',
            basket_id=self.basket_id,
        )

        self.rate2 = ShippingRate.objects.create(
            name='rate2',
            rate=97,
            carrier='rate2c',
            description='rate2d',
            basket_id=self.basket_id,
            destination=self.address,
        )

        self.rate3 = ShippingRate.objects.create(
            name='rate3',
            rate=95,
            carrier='rate3c',
            description='rate3d',
            destination=self.address,
        )

        self.rate4 = ShippingRate.objects.create(
            name='rate4',
            rate=93,
            carrier='rate4c',
            description='rate4d',
        )
        self.rate4.countries.add(self.country)

        self.rate5 = ShippingRate.objects.create(
            name='rate5',
            rate=95,
            carrier='rate5c',
            description='rate5d',
            destination=self.address2,
        )
예제 #6
0
 def test_create_order(self):
     shipping_rate = 0
     basket_items = [
         BasketItemFactory(basket_id=self.basket_id),
         BasketItemFactory(basket_id=self.basket_id)
     ]
     order = create_order(basket_items, self.addresses, self.email,
                          shipping_rate)
     self.assertIsNotNone(order)
     self.assertEqual(self.email, order.email)
     self.assertEqual(order.items.count(), 2)
예제 #7
0
 def test_post_checkout_billing(self):
     """
     Test using an alternate shipping
     address in the checkout view
     """
     country = CountryFactory()
     request = RequestFactory().post(
         reverse_lazy('longclaw_checkout_view'),
         {
             'shipping-name': 'bob',
             'shipping-line_1': 'blah blah',
             'shipping-postcode': 'ytxx 23x',
             'shipping-city': 'London',
             'shipping-country': country.pk,
             'billing-name': 'john',
             'billing-line_1': 'somewhere',
             'billing-postcode': 'lmewrewr',
             'billing-city': 'London',
             'billing-country': country.pk,
             'email': '*****@*****.**',
             'different_billing_address': True
         }
     )
     request.session = {}
     bid = basket_id(request)
     BasketItemFactory(basket_id=bid)
     response = CheckoutView.as_view()(request)
     self.assertEqual(response.status_code, 302)
예제 #8
0
 def setUp(self):
     self.shipping_address = AddressFactory()
     self.billing_address = AddressFactory()
     self.email = "*****@*****.**"
     self.request = RequestFactory().get('/')
     self.request.session = {}
     self.request.site = Site.find_for_request(self.request)
     self.basket_id = basket_id(self.request)
     BasketItemFactory(basket_id=self.basket_id)
예제 #9
0
    def setUp(self):
        self.country = CountryFactory()
        self.address = AddressFactory()

        request = RequestFactory().get('/')
        request.session = {}

        self.basket_id = 'foo'
        BasketItemFactory(basket_id=self.basket_id)
        BasketItemFactory(basket_id=self.basket_id)

        self.rate1 = ShippingRate.objects.create(
            name='rate1',
            rate=99,
            carrier='rate1c',
            description='rate1d',
            basket_id=self.basket_id,
        )

        self.rate2 = ShippingRate.objects.create(
            name='rate2',
            rate=97,
            carrier='rate2c',
            description='rate2d',
            basket_id=self.basket_id,
            destination=self.address,
        )

        self.rate3 = ShippingRate.objects.create(
            name='rate3',
            rate=95,
            carrier='rate3c',
            description='rate3d',
            destination=self.address,
        )

        self.rate4 = ShippingRate.objects.create(
            name='rate4',
            rate=93,
            carrier='rate4c',
            description='rate4d',
        )
        self.rate4.countries.add(self.country)
예제 #10
0
    def setUp(self):
        self.country = CountryFactory()
        self.address = AddressFactory()
        self.address_data = {
            'name': 'JANE DOE',
            'line_1': '1600 Pennsylvania Ave NW',
            'city': 'DC',
            'postcode': '20500',
            'country': self.country.pk,
        }

        request = RequestFactory().get('/')
        request.session = {}
        self.bid = bid = basket_id(request)
        self.item = BasketItemFactory(basket_id=bid)
        BasketItemFactory(basket_id=bid)

        self.ratedAddress = address = AddressFactory()

        self.rate1 = ShippingRate.objects.create(
            name='98d17c43-7e20-42bd-b603-a4c83c829c5a',
            rate=99,
            carrier='8717ca67-4691-4dff-96ec-c43cccd15241',
            description='313037e1-644a-4570-808a-f9ba82ecfb34',
            basket_id=bid,
        )

        self.rate2 = ShippingRate.objects.create(
            name='8e721550-594c-482b-b512-54dc1744dff8',
            rate=97,
            carrier='4f4cca35-1a7a-47ec-ab38-a9918e0c04af',
            description='eacb446d-eb17-4ea7-82c1-ac2f62a53a7d',
            basket_id=bid,
            destination=address,
        )

        self.rate3 = ShippingRate.objects.create(
            name='72991859-dc0b-463e-821a-bf8b04aaed2c',
            rate=95,
            carrier='0aa3c318-b045-4a96-a456-69b4cc71d46a',
            description='78b03c47-b20f-4f91-8161-47340367fb34',
            destination=address,
        )
예제 #11
0
 def test_checkout_prepaid(self):
     """
     Test api endpoint checkout/prepaid/
     """
     BasketItemFactory(basket_id=self.basket_id)
     data = {
         'address': self.addresses,
         'email': self.email,
         'transaction_id': 'blahblah'
     }
     self.post_test(data, 'longclaw_checkout_prepaid', format='json')
예제 #12
0
 def test_post_checkout_invalid(self):
     """
     Test posting an invalid form.
     This should return a 200 response - rerendering
     the form page with the errors
     """
     request = RequestFactory().post(reverse('longclaw_checkout_view'))
     request.session = {}
     bid = basket_id(request)
     BasketItemFactory(basket_id=bid)
     response = CheckoutView.as_view()(request)
     self.assertEqual(response.status_code, 200)
예제 #13
0
class BasketModelTest(TestCase):
    def setUp(self):
        self.item = BasketItemFactory()

    def test_increase_quantity(self):
        self.item.increase_quantity()
        self.assertEqual(self.item.quantity, 2)

        self.item.increase_quantity(quantity=10)
        self.assertEqual(self.item.quantity, 12)

    def test_decrease_quantity(self):
        self.item.quantity = 5
        self.item.save()
        self.item.decrease_quantity()
        self.assertEqual(self.item.quantity, 4)
예제 #14
0
 def test_post_checkout(self):
     """
     Test correctly posting to the checkout view
     """
     country = CountryFactory()
     request = RequestFactory().post(
         reverse('longclaw_checkout_view'), {
             'shipping-name': 'bob',
             'shipping-line_1': 'blah blah',
             'shipping-postcode': 'ytxx 23x',
             'shipping-city': 'London',
             'shipping-country': country.pk,
             'email': '*****@*****.**'
         })
     request.session = {}
     bid = basket_id(request)
     BasketItemFactory(basket_id=bid)
     response = CheckoutView.as_view()(request)
     self.assertEqual(response.status_code, 302)
예제 #15
0
 def add_item_to_basket(self):
     BasketItemFactory(basket_id='foo')
예제 #16
0
 def setUp(self):
     request = RequestFactory().get('/')
     request.session = {}
     bid = basket_id(request)
     BasketItemFactory(basket_id=bid)
예제 #17
0
 def setUp(self):
     self.item = BasketItemFactory()