Просмотр исходного кода

fixed tests for delete user endpoint

Rafał Pitoń 9 лет назад
Родитель
Сommit
7b4bcc6fbb
2 измененных файлов с 8 добавлено и 5 удалено
  1. 1 3
      misago/users/api/users.py
  2. 7 2
      misago/users/tests/test_users_api.py

+ 1 - 3
misago/users/api/users.py

@@ -1,5 +1,3 @@
-from distutils.util import strtobool
-
 from django.conf import settings
 from django.conf import settings
 from django.contrib.auth import get_user_model
 from django.contrib.auth import get_user_model
 from django.core.exceptions import PermissionDenied
 from django.core.exceptions import PermissionDenied
@@ -189,7 +187,7 @@ class UserViewSet(viewsets.GenericViewSet):
             with transaction.atomic():
             with transaction.atomic():
                 profile.lock()
                 profile.lock()
 
 
-                if strtobool(request.data.get('with_content', '')):
+                if request.data.get('with_content'):
                     profile.delete_content()
                     profile.delete_content()
                 else:
                 else:
                     forums_to_sync = set()
                     forums_to_sync = set()

+ 7 - 2
misago/users/tests/test_users_api.py

@@ -1,4 +1,5 @@
 from datetime import timedelta
 from datetime import timedelta
+import json
 
 
 from django.contrib.auth import get_user_model
 from django.contrib.auth import get_user_model
 
 
@@ -420,7 +421,9 @@ class UserDeleteTests(AuthenticatedUserTestCase):
             'can_delete_users_with_less_posts_than': 10,
             'can_delete_users_with_less_posts_than': 10,
         })
         })
 
 
-        response = self.client.post(self.link, data={'with_content': True})
+        response = self.client.post(self.link, json.dumps({
+            'with_content': True
+        }), content_type="application/json")
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
         User = get_user_model()
         User = get_user_model()
@@ -437,7 +440,9 @@ class UserDeleteTests(AuthenticatedUserTestCase):
             'can_delete_users_with_less_posts_than': 10,
             'can_delete_users_with_less_posts_than': 10,
         })
         })
 
 
-        response = self.client.post(self.link, data={'with_content': False})
+        response = self.client.post(self.link, json.dumps({
+            'with_content': False
+        }), content_type="application/json")
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
         User = get_user_model()
         User = get_user_model()