Пример #1
0
 def test_get(self):
     cart = Cart.objects.create_active()
     product = model_factory(Product, save=True)
     product_variation = model_factory(ProductVariation, product=product,
                                       save=True)
     user = model_factory(User, save=True)
     request = RequestFactory().get('/')
     request.user = user
     request.cart = cart
     view = CartItemAddView()
     with patch('salest.cart.models.Cart.add_product', Mock()) as test_cart:
         view.get(request, product_variation.id)
         test_cart.assert_called_once_with(product_variation)
Пример #2
0
from django.conf.urls.defaults import patterns, url
from django.views.generic import DetailView

from salest.cart.views import CartItemAddView, CartItemUpdateView, CartItemDeleteView, CartDetailView

from salest.discounts.models import Discount

urlpatterns = patterns(
    "",
    url(r"^$", CartDetailView.as_view(), name="detail"),
    url(r"^cart/add/(?P<product_id>\d+)/$", CartItemAddView.as_view(), name="add"),
    url(r"^cart/edit/(?P<pk>\d+)/$", CartItemUpdateView.as_view(), name="edit"),
    url(r"^cart/delete/(?P<pk>\d+)/$", CartItemDeleteView.as_view(), name="delete"),
    url(
        r"^users_discount/details/(?P<pk>\d+)/$",
        DetailView.as_view(model=Discount, context_object_name="object_details"),
        name="users_discount_details",
    ),
    url(
        r"^products_discount/details/(?P<pk>\d+)/$",
        DetailView.as_view(model=Discount, context_object_name="object_details"),
        name="products_discount_details",
    ),
    url(
        r"^products_categories_discount/details/(?P<pk>\d+)/$",
        DetailView.as_view(model=Discount, context_object_name="object_details"),
        name="products_categories_discount_details",
    ),
)