def save_client(self, data): try: client = Client() client.name = data.get('name') client.address = data.get('address') client.ruc = data.get('ruc') client.save() self.save_type_detail(client, data.get('type')) return client, self.SAVE_SUCCESSFUL except IntegrityError, e: return None, self.SAVE_RUC_ERROR
def test_list_view_client(self): """ Tests data: List """ view = ClientListView.as_view() request = self.request_factory.get(reverse('client_list')) request.user = self.user response = view(request) self.assertEqual(response.status_code, 200) self.assertEqual(response.context_data['object_list'].count(), 3) client = Client() client.name = 'Client Test' client.ruc = '2345654321' client.address = 'Direccion' client.save() response = view(request) self.assertEqual(response.context_data['object_list'].count(), 4)
def test_list_view_client(self): """ Tests data: List """ view = ClientListView.as_view() request = self.request_factory.get(reverse("client_list")) request.user = self.user response = view(request) self.assertEqual(response.status_code, 200) self.assertEqual(response.context_data["object_list"].count(), 3) client = Client() client.name = "Client Test" client.ruc = "2345654321" client.address = "Direccion" client.save() response = view(request) self.assertEqual(response.context_data["object_list"].count(), 4)
def test_data_list(self): """ Tests List """ self.insert_test_data() view = ClientDataListView.as_view() request = self.request_factory.get(reverse('client_data_list')) request.user = self.user response = view(request) self.assertEqual(response.status_code, 200) content = json.loads(response._container[0]) self.assertEqual(len(content.get('client')), 3) client = Client() client.name = 'Client Test' client.ruc = '2345654321' client.address = 'Direccion' client.save() response = view(request) content = json.loads(response._container[0]) self.assertEqual(len(content.get('client')), 4)
def test_data_list(self): """ Tests List """ self.insert_test_data() view = ClientDataListView.as_view() request = self.request_factory.get(reverse("client_data_list")) request.user = self.user response = view(request) self.assertEqual(response.status_code, 200) content = json.loads(response._container[0]) self.assertEqual(len(content.get("client")), 3) client = Client() client.name = "Client Test" client.ruc = "2345654321" client.address = "Direccion" client.save() response = view(request) content = json.loads(response._container[0]) self.assertEqual(len(content.get("client")), 4)
def insert_client(self): if not Client.objects.filter(name='Productor').exists(): client_productor = Client() client_productor.name = 'Productor' client_productor.ruc = '12345678901' client_productor.save() client_productor.type_client.add(TypeClient.objects.get(name= 'Productora')) if not Client.objects.filter(name='Realizadora').exists(): client_director = Client() client_director.name = 'Realizadora' client_director.ruc = '12333678901' client_director.save() client_director.type_client.add(TypeClient.objects.get(name='Realizadora')) if not Client.objects.filter(name='Agencia').exists(): client_agency = Client() client_agency.name = 'Agencia' client_agency.ruc = '12555678901' client_agency.save() client_agency.type_client.add(TypeClient.objects.get(name= 'Agencia'))
def insert_client(self): if not Client.objects.filter(name='Productor').exists(): client_productor = Client() client_productor.name = 'Productor' client_productor.ruc = '12345678901' client_productor.save() client_productor.type_client.add( TypeClient.objects.get(name='Productora')) if not Client.objects.filter(name='Realizadora').exists(): client_director = Client() client_director.name = 'Realizadora' client_director.ruc = '12333678901' client_director.save() client_director.type_client.add( TypeClient.objects.get(name='Realizadora')) if not Client.objects.filter(name='Agencia').exists(): client_agency = Client() client_agency.name = 'Agencia' client_agency.ruc = '12555678901' client_agency.save() client_agency.type_client.add( TypeClient.objects.get(name='Agencia'))