From 1b8d7d3ad514b004c9269dbc52a281c2f22de8ea Mon Sep 17 00:00:00 2001 From: hohoTT <609029365@qq.com> Date: Sat, 8 Aug 2015 14:59:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=AF=86=E7=A0=81=E6=97=B6=EF=BC=8C=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E6=98=AF=E5=90=A6=E7=BC=96=E8=BE=91=E7=9A=84=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account/serializers.py | 2 +- account/tests.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/account/serializers.py b/account/serializers.py index d82b36db..358ced71 100644 --- a/account/serializers.py +++ b/account/serializers.py @@ -41,6 +41,6 @@ class EditUserSerializer(serializers.Serializer): id = serializers.IntegerField() username = serializers.CharField(max_length=30) real_name = serializers.CharField(max_length=30) - password = serializers.CharField(max_length=30, min_length=6, required=True) + password = serializers.CharField(max_length=30, min_length=6, required=False, default=None) email = serializers.EmailField(max_length=254) admin_type = serializers.IntegerField(default=0) diff --git a/account/tests.py b/account/tests.py index 41158294..ca69832b 100644 --- a/account/tests.py +++ b/account/tests.py @@ -4,6 +4,7 @@ import json from django.core.urlresolvers import reverse from django.test import TestCase, Client from django.http import HttpResponse +from django.contrib import auth from rest_framework.test import APITestCase, APIClient from rest_framework.views import APIView @@ -194,11 +195,18 @@ class UserAdminAPITest(APITestCase): self.assertEqual(response.data, {"code": 1, "data": u"该用户不存在!"}) def test_success_user_edit_not_password(self): - data = {"id": 1, "username": "test0", "real_name": "test00", "password": "aaaaaa", + data = {"id": 1, "username": "test0", "real_name": "test00", "email": "60@qq.com", "admin_type": "2"} response = self.client.put(self.url, data=data) self.assertEqual(response.data["code"], 0) + def test_success_user_edit_change_password(self): + data = {"id": 1, "username": "test0", "real_name": "test00", "password": "111111", + "email": "60@qq.com", "admin_type": "2"} + response = self.client.put(self.url, data=data) + self.assertEqual(response.data["code"], 0) + self.assertIsNotNone(auth.authenticate(username="test0", password="111111")) + @login_required def login_required_FBV_test_without_args(request):