mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-09-22 00:43:20 +00:00
Accept Merge Request #158 更新 : (dev-sxw -> for-contest)
Merge Request: 更新 Created By: @esp Accepted By: @esp URL: https://coding.net/u/virusdefender/p/qduoj/git/merge/158
This commit is contained in:
commit
c455fb5464
@ -140,12 +140,12 @@ class UserAdminAPITest(APITestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.client = APIClient()
|
self.client = APIClient()
|
||||||
self.url = reverse("user_admin_api")
|
self.url = reverse("user_admin_api")
|
||||||
user = User.objects.create(username="testx", real_name="xx", admin_type=SUPER_ADMIN)
|
self.user = User.objects.create(username="testx", real_name="xx", admin_type=SUPER_ADMIN)
|
||||||
user.set_password("testxx")
|
self.user.set_password("testxx")
|
||||||
user.save()
|
self.user.save()
|
||||||
user = User.objects.create(username="testy", real_name="yy", admin_type=SUPER_ADMIN)
|
self.user = User.objects.create(username="testy", real_name="yy", admin_type=SUPER_ADMIN)
|
||||||
user.set_password("testyy")
|
self.user.set_password("testyy")
|
||||||
user.save()
|
self.user.save()
|
||||||
self.client.login(username="testx", password="testxx")
|
self.client.login(username="testx", password="testxx")
|
||||||
|
|
||||||
# 以下是编辑用户的测试
|
# 以下是编辑用户的测试
|
||||||
@ -164,19 +164,19 @@ class UserAdminAPITest(APITestCase):
|
|||||||
self.assertEqual(response.data, {"code": 1, "data": u"该用户不存在!"})
|
self.assertEqual(response.data, {"code": 1, "data": u"该用户不存在!"})
|
||||||
|
|
||||||
def test_username_exists(self):
|
def test_username_exists(self):
|
||||||
data = {"id": 1, "username": "testy", "real_name": "test00",
|
data = {"id": self.user.id, "username": "testy", "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_user_edit_not_password_successfully(self):
|
def test_user_edit_not_password_successfully(self):
|
||||||
data = {"id": 1, "username": "test0", "real_name": "test00",
|
data = {"id": self.user.id, "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_user_edit_change_password_successfully(self):
|
def test_user_edit_change_password_successfully(self):
|
||||||
data = {"id": 1, "username": "test0", "real_name": "test00", "password": "111111",
|
data = {"id": self.user.id, "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)
|
||||||
self.assertEqual(response.data["code"], 0)
|
self.assertEqual(response.data["code"], 0)
|
||||||
|
@ -370,7 +370,7 @@ class ContestProblemAdminAPItEST(APITestCase):
|
|||||||
|
|
||||||
def test_query_contest_problem_exists_by_contest_id(self):
|
def test_query_contest_problem_exists_by_contest_id(self):
|
||||||
self.client.login(username="test3", password="testaa")
|
self.client.login(username="test3", password="testaa")
|
||||||
response = self.client.get(self.url + "?contest_id=1")
|
response = self.client.get(self.url + "?contest_id="+ str(self.global_contest.id))
|
||||||
self.assertEqual(response.data["code"], 0)
|
self.assertEqual(response.data["code"], 0)
|
||||||
self.assertEqual(len(response.data["data"]), 0)
|
self.assertEqual(len(response.data["data"]), 0)
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class ProblemAdminTest(APITestCase):
|
|||||||
self.assertEqual(response.data, {"code": 1, "data": u"题目不存在"})
|
self.assertEqual(response.data, {"code": 1, "data": u"题目不存在"})
|
||||||
|
|
||||||
def test_query_problem_exists(self):
|
def test_query_problem_exists(self):
|
||||||
data = {"problem_id": 1}
|
data = {"problem_id": self.problem.id}
|
||||||
response = self.client.get(self.url, data=data)
|
response = self.client.get(self.url, data=data)
|
||||||
self.assertEqual(response.data["code"], 0)
|
self.assertEqual(response.data["code"], 0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user