def test_code_validation(self):
     request = self.factory.post('', {'code': 'invalid code'})
     request.user = AnonymousUser()
     request.session = {}
     response = CartDiscountCodeCreateView.as_view()(request)
     self.assertEquals(response.status_code, 200)
     self.assertIn('code', response.context_data['form'].errors)
Пример #2
0
from django.conf.urls.defaults import url, patterns

from discount.views import CartDiscountCodeDeleteView, CartDiscountCodeCreateView


urlpatterns = patterns('',
    url(r'^discount_code/$', CartDiscountCodeCreateView.as_view(), 
        name='discount_cartdiscountcode_create'),
    url(r'^discount_code/delete/$', CartDiscountCodeDeleteView.as_view(), 
        name='discount_cartdiscountcode_delete'),
    )

Пример #3
0
try:
    # django 1.6+
    from django.conf.urls import patterns, url
except ImportError:
    # django <1.6
    from django.conf.urls.defaults import patterns, url

from discount.views import CartDiscountCodeDeleteView, CartDiscountCodeCreateView

urlpatterns = patterns(
    '',
    url(r'^discount_code/$',
        CartDiscountCodeCreateView.as_view(),
        name='discount_cartdiscountcode_create'),
    url(r'^discount_code/delete/$',
        CartDiscountCodeDeleteView.as_view(),
        name='discount_cartdiscountcode_delete'),
)