修复测试同名问题

This commit is contained in:
virusdefender 2015-08-14 10:36:23 +08:00
parent fd07ff4666
commit 174752b9b1

View File

@ -179,37 +179,28 @@ class UserAdminAPITest(APITestCase):
response = self.client.get(self.url + "?keyword=test1") response = self.client.get(self.url + "?keyword=test1")
self.assertEqual(response.data["code"], 0) self.assertEqual(response.data["code"], 0)
class UserAdminAPITest(APITestCase):
def setUp(self):
self.client = APIClient()
self.url = reverse("user_admin_api")
user = User.objects.create(username="test", admin_type=SUPER_ADMIN)
user.set_password("testaa")
user.save()
def test_put_invalid_data(self): def test_put_invalid_data(self):
self.client.login(username="test", password="testaa") self.client.login(username="testx", password="testxx")
data = {"username": "test", "password": "testaa", "email": "60@qq.com", "admin_type": "2"} data = {"username": "test", "password": "testaa", "email": "60@qq.com", "admin_type": "2"}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)
self.assertEqual(response.data["code"], 1) self.assertEqual(response.data["code"], 1)
def test_user_does_not_exist(self): def test_user_does_not_exist(self):
self.client.login(username="test", password="testaa") self.client.login(username="testx", password="testxx")
data = {"id": 2, "username": "test0", "real_name": "test00", data = {"id": 2, "username": "test0", "real_name": "test00",
"password": "testaa","email": "60@qq.com", "admin_type": "2"} "password": "testaa","email": "60@qq.com", "admin_type": "2"}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)
self.assertEqual(response.data, {"code": 1, "data": u"该用户不存在!"}) self.assertEqual(response.data, {"code": 1, "data": u"该用户不存在!"})
def test_success_user_edit_not_password(self): def test_success_user_edit_not_password(self):
self.client.login(username="test", password="testaa") self.client.login(username="testx", password="testxx")
data = {"id": 1, "username": "test0", "real_name": "test00", data = {"id": 1, "username": "test0", "real_name": "test00",
"email": "60@qq.com", "admin_type": "2"} "email": "60@qq.com", "admin_type": "2"}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)
self.assertEqual(response.data["code"], 0) self.assertEqual(response.data["code"], 0)
def test_success_user_edit_change_password(self): def test_success_user_edit_change_password(self):
self.client.login(username="test", password="testaa") self.client.login(username="testx", password="testxx")
data = {"id": 1, "username": "test0", "real_name": "test00", "password": "111111", data = {"id": 1, "username": "test0", "real_name": "test00", "password": "111111",
"email": "60@qq.com", "admin_type": "2"} "email": "60@qq.com", "admin_type": "2"}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)