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)