[前台]修改修改密码功能,api添加@login_requrie,去掉界面和api中的username字段,这个从request可以拿到,要用户输入反而不好弄了,也没必要,顺便改了测试[CI不能SKIP]

This commit is contained in:
esp
2015-09-01 19:04:07 +08:00
parent 850815a49f
commit 0e322da9d6
5 changed files with 7 additions and 21 deletions

View File

@@ -123,22 +123,13 @@ class UserChangePasswordAPITest(APITestCase):
user = User.objects.create(username="test")
user.set_password("aaabbb")
user.save()
self.client.login(username="test",password="aaabbb")
def test_error_old_password(self):
data = {"username": "test", "old_password": "aaaccc", "new_password": "aaaddd"}
data = {"old_password": "aaaccc", "new_password": "aaaddd"}
response = self.client.post(self.url, data=data)
self.assertEqual(response.data, {"code": 1, "data": u"密码不正确,请重新修改!"})
def test_invalid_data_format(self):
data = {"old_password": "aaa", "new_password": "aaaddd"}
response = self.client.post(self.url, data=data)
self.assertEqual(response.data["code"], 1)
def test_username_does_not_exist(self):
data = {"username": "test1", "old_password": "aaabbb", "new_password": "aaaddd"}
response = self.client.post(self.url, data=data)
self.assertEqual(response.data["code"], 1)
def test_success_change_password(self):
data = {"username": "test", "old_password": "aaabbb", "new_password": "aaaccc"}
response = self.client.post(self.url, data=data)