def test_user_remove(self): user_str = 'user_remove' user_to_delete = User.objects.create_user(username=user_str, email='*****@*****.**', password='******') user_to_delete.is_staff = True user_to_delete.is_superuser = True user_to_delete.is_active = True user_to_delete.save() self.assertEqual(User.objects.filter(username=user_str).count(), 1) self.data['action'] = 'remove' response = self.client.post(reverse(USER_EDIT, args=(user_to_delete.pk, )), self.data, follow=True) self.assertEqual(response.status_code, 200) user_to_delete = get_object_or_404(User, pk=user_to_delete.pk) self.assertEqual(user_to_delete.is_active, False) # Create an instance of a GET request. request = self.factory.get( reverse(USER_EDIT, args=[ user_to_delete.pk, ])) request.user = self.user response = user_update(request, user_id=user_to_delete.pk) self.assertEqual(response, None)
def test_user_remove(self): """ Testa deletar usuario """ user_str = 'user_remove' user_to_delete = User.objects.create_user(username=user_str, email='*****@*****.**', password='******') user_to_delete.is_staff = True user_to_delete.is_superuser = True user_to_delete.is_active = True user_to_delete.save() self.assertEqual(User.objects.filter(username=user_str).count(), 1) self.data['action'] = 'remove' response = self.client.post(reverse(USER_EDIT, args=(user_to_delete.pk,)), self.data, follow=True) self.assertEqual(response.status_code, 200) user_to_delete = get_object_or_404(User, pk=user_to_delete.pk) self.assertEqual(user_to_delete.is_active, False) # Create an instance of a GET request. request = self.factory.get(reverse(USER_EDIT, args=[user_to_delete.pk, ])) request.user = self.user response = user_update(request, user_id=user_to_delete.pk) self.assertEqual(response, None)
def test_user_update_get(self): # Create an instance of a GET request. request = self.factory.get(reverse(USER_EDIT, args=[self.user.pk])) request.user = self.user # Test view() as if it were deployed at /quiz/patient/%id response = user_update(request, user_id=self.user.pk) self.assertEqual(response.status_code, 200)
def test_user_read(self): self.data['login_enabled'] = True # Create an instance of a GET request. request = self.factory.get(reverse(USER_EDIT, args=[self.user.pk])) request.user = self.user # Test view() as if it were deployed at /quiz/patient/%id response = user_update(request, user_id=self.user.pk) self.assertEqual(response.status_code, 200) response = self.client.post(reverse(USER_EDIT, args=[self.user.pk]), self.data) self.assertEqual(response.status_code, 302)