Esempio n. 1
0
    def test_update_view_brand(self):
        """
        Tests data: Update
        """
        self.assertEqual(Client.objects.all().count(), 3)
        client = Client.objects.get(name="Productora")

        request = self.request_factory.get(reverse("client_edit", kwargs={"pk": client.id}))
        request.user = self.user
        view = ClientUpdateView.as_view()
        response = view(request, pk=client.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(Client.objects.all().count(), 3)
        self.assertEqual(client.name, "Productora")
        # Post
        data = {
            "pk": client.id,
            "name": "actualizado",
            "ruc": "2323232323",
            "address": "mi direccion",
            "type_client": [TypeClient.objects.get(name="Productora").id],
        }

        url_kwargs = {"pk": client.id}
        url = reverse("client_edit", kwargs=url_kwargs)
        request = self.request_factory.post(url, data=data)
        request.user = self.user
        view = ClientUpdateView.as_view()
        response = view(request, **data)

        client = Client.objects.get(pk=1)
        self.assertEqual(client.name, "actualizado")
        self.assertEqual(response.status_code, 302)
Esempio n. 2
0
    def test_update_view_brand(self):
        """
        Tests data: Update
        """
        self.assertEqual(Client.objects.all().count(), 3)
        client = Client.objects.get(name='Productora')

        request = self.request_factory.get(
            reverse('client_edit', kwargs={'pk': client.id}))
        request.user = self.user
        view = ClientUpdateView.as_view()
        response = view(request, pk=client.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(Client.objects.all().count(), 3)
        self.assertEqual(client.name, 'Productora')
        #Post
        data = {
            'pk': client.id,
            'name': "actualizado",
            'ruc': '2323232323',
            'address': 'mi direccion',
            'type_client': [TypeClient.objects.get(name='Productora').id]
        }

        url_kwargs = {'pk': client.id}
        url = reverse('client_edit', kwargs=url_kwargs)
        request = self.request_factory.post(url, data=data)
        request.user = self.user
        view = ClientUpdateView.as_view()
        response = view(request, **data)

        client = Client.objects.get(pk=1)
        self.assertEqual(client.name, 'actualizado')
        self.assertEqual(response.status_code, 302)
Esempio n. 3
0
from django.conf.urls import url, patterns
from apps.sp.views.panel.Client import ClientListView, ClientCreateView, \
    ClientUpdateView, ClientDeleteView, ClientDataListView, \
    TypeClientDataListView, ClientCreateDataJson


urlpatterns = patterns('',

                       #Client
                       url(r'^list/$',
                           ClientListView.as_view(),
                           name='client_list'),
                       url(r'^create/$',
                           ClientCreateView.as_view(),
                           name='client_create'),
                       url(r'^edit/(?P<pk>\d+)/$',
                           ClientUpdateView.as_view(),
                           name='client_edit'),
                       url(r'^delete/(?P<pk>\d+)/$',
                           ClientDeleteView.as_view(),
                           name='client_delete'),
                       url(r'^data-list/$',
                           ClientDataListView.as_view(),
                           name='client_data_list'),
                        url(r'^type-data-list/$',
                            TypeClientDataListView.as_view(),
                            name='type_client_data_list'),
                        url(r'^json-create/$',
                            ClientCreateDataJson.as_view(),
                            name='client_json_create')
                       )
Esempio n. 4
0
# -*- coding: utf-8 -*-

from django.conf.urls import url, patterns
from apps.sp.views.panel.Client import ClientListView, ClientCreateView, \
    ClientUpdateView, ClientDeleteView, ClientDataListView, \
    TypeClientDataListView, ClientCreateDataJson

urlpatterns = patterns(
    '',

    #Client
    url(r'^list/$', ClientListView.as_view(), name='client_list'),
    url(r'^create/$', ClientCreateView.as_view(), name='client_create'),
    url(r'^edit/(?P<pk>\d+)/$', ClientUpdateView.as_view(),
        name='client_edit'),
    url(r'^delete/(?P<pk>\d+)/$',
        ClientDeleteView.as_view(),
        name='client_delete'),
    url(r'^data-list/$', ClientDataListView.as_view(),
        name='client_data_list'),
    url(r'^type-data-list/$',
        TypeClientDataListView.as_view(),
        name='type_client_data_list'),
    url(r'^json-create/$',
        ClientCreateDataJson.as_view(),
        name='client_json_create'))