def setUp(self): self.creator = OrderCreator() self.basket = factories.create_basket(empty=True) self.site1 = factories.SiteFactory() self.site2 = factories.SiteFactory() self.surcharges = SurchargeApplicator().get_applicable_surcharges( self.basket)
def test_multi_site(self): basket = factories.create_basket(empty=True) site1 = factories.SiteFactory() site2 = factories.SiteFactory() request = HttpRequest() request.META['SERVER_PORT'] = 80 request.META['SERVER_NAME'] = site1.domain user = factories.UserFactory() add_product(basket, D('12.00')) shipping_method = Free() shipping_charge = shipping_method.calculate(basket) order_total = OrderTotalCalculator().calculate(basket, shipping_charge) billing_address = factories.BillingAddressFactory() shipping_address = factories.ShippingAddressFactory() order_submission_data = {'user': user, 'order_number': '12345', 'basket': basket, 'shipping_method': shipping_method, 'shipping_charge': shipping_charge, 'order_total': order_total, 'billing_address': billing_address, 'shipping_address': shipping_address, 'request': request} OrderPlacementMixin().place_order(**order_submission_data) order1 = Order.objects.get(number='12345') self.assertEqual(order1.site, site1) add_product(basket, D('12.00')) request.META['SERVER_NAME'] = site2.domain order_submission_data['order_number'] = '12346' order_submission_data['request'] = request OrderPlacementMixin().place_order(**order_submission_data) order2 = Order.objects.get(number='12346') self.assertEqual(order2.site, site2)
def test_multi_sites(self): site1 = factories.SiteFactory() site2 = factories.SiteFactory() add_product(self.basket, D('12.00')) place_order(self.creator, basket=self.basket, order_number='12345', site=site1) order1 = Order.objects.get(number='12345') self.assertEquals(order1.site, site1) add_product(self.basket, D('12.00')) place_order(self.creator, basket=self.basket, order_number='12346', site=site2) order2 = Order.objects.get(number='12346') self.assertEquals(order2.site, site2)
def setUp(self): self.creator = OrderCreator() self.basket = factories.create_basket(empty=True) self.site1 = factories.SiteFactory() self.site2 = factories.SiteFactory()