def test_ga_ecommerce_tracking(self): """ """ shop = muecke.core.utils.get_default_shop() shop.google_analytics_id = "" shop.ga_site_tracking = False shop.ga_ecommerce_tracking = False shop.save() session = SessionStore() rf = RequestFactory() request = rf.get('/') request.session = session template = get_template_from_string( """{% load muecke_tags %}{% google_analytics_ecommerce %}""") content = template.render(Context({"request": request})) self.failIf(content.find("pageTracker") != -1) # Enter a google_analytics_id shop.google_analytics_id = "UA-XXXXXXXXXX" shop.save() # Simulating a new request rf = RequestFactory() request = rf.get('/') request.session = session # But this is not enough content = template.render(Context({"request": request})) self.failIf(content.find("pageTracker") != -1) # It has to be activated first shop.ga_ecommerce_tracking = True shop.save() # Simulating a new request rf = RequestFactory() request = rf.get('/') request.session = session # But this is still not enough content = template.render(Context({"request": request})) self.failIf(content.find("pageTracker") != -1) # There has to be an order within the session session["order"] = Order() # Now it works and "pageTracker" is found content = template.render(Context({"request": request})) self.failIf(content.find("pageTracker") == -1)
def test_manage_urls_anonymous(self): """Tests that all manage urls cannot accessed by anonymous user. """ rf = RequestFactory() request = rf.get("/") request.user = AnonymousUser() from muecke.manage.urls import urlpatterns for url in urlpatterns: result = url.callback(request) self.failUnless(result["Location"].startswith("/login/?next=/"))
def setUp(self): """ """ session = SessionStore() rf = RequestFactory() self.request = rf.get('/') self.request.session = session self.request.user = AnonymousUser() tax = Tax.objects.create(rate=19) shipping_method = ShippingMethod.objects.create( name="Standard", active=True, price=1.0, tax=tax ) payment_method = PaymentMethod.objects.create( name="Direct Debit", active=True, tax=tax, ) us = Country.objects.get(code="us") ie = Country.objects.get(code="ie") address1 = Address.objects.create( firstname="John", lastname="Doe", company_name="Doe Ltd.", line1="Street 42", city="Gotham City", zip_code="2342", country=ie, phone="555-111111", email="*****@*****.**", ) address2 = Address.objects.create( firstname="Jane", lastname="Doe", company_name="Doe Ltd.", line1="Street 43", city="Smallville", zip_code="2443", country=us, phone="666-111111", email="*****@*****.**", ) self.customer = Customer.objects.create( session=session.session_key, selected_shipping_method=shipping_method, selected_payment_method=payment_method, selected_shipping_address=address1, selected_invoice_address=address2, ) self.p1 = Product.objects.create( name="Product 1", slug="product-1", sku="sku-1", price=1.1, tax=tax, active=True, ) self.p2 = Product.objects.create( name="Product 2", slug="product-2", sku="sku-2", price=2.2, tax=tax, active=True, ) cart = Cart.objects.create( session=session.session_key ) item = CartItem.objects.create( cart=cart, product=self.p1, amount=2, ) item = CartItem.objects.create( cart=cart, product=self.p2, amount=3, )
def setUp(self): """ """ session = SessionStore() rf = RequestFactory() self.request = rf.get('/') self.request.session = session self.request.user = AnonymousUser() tax = Tax.objects.create(rate=19) discount = Discount.objects.create(name="Summer", value=10.0, type=0, tax=tax) shipping_method = ShippingMethod.objects.create(name="Standard", active=True, price=1.0, tax=tax) payment_method = PaymentMethod.objects.create( name="Direct Debit", active=True, tax=tax, ) us = Country.objects.get(code="us") address1 = Address.objects.create( firstname="John", lastname="Doe", company_name="Doe Ltd.", line1="Street 42", city="Gotham City", zip_code="2342", country=us, phone="555-111111", email="*****@*****.**", ) self.customer = Customer.objects.create( session=session.session_key, selected_shipping_method=shipping_method, selected_payment_method=payment_method, selected_shipping_address=address1, selected_invoice_address=address1, ) self.p1 = Product.objects.create( name="Product 1", slug="product-1", sku="sku-1", price=1.1, tax=tax, active=True, ) self.p2 = Product.objects.create( name="Product 2", slug="product-2", sku="sku-2", price=2.2, tax=tax, active=True, ) cart = Cart.objects.create(session=session.session_key) item = CartItem.objects.create( cart=cart, product=self.p1, amount=2, ) item = CartItem.objects.create( cart=cart, product=self.p2, amount=3, )