From 2252107a8017e58628166cc010f421724e334962 Mon Sep 17 00:00:00 2001 From: hohoTT <609029365@qq.com> Date: Sat, 29 Aug 2015 15:20:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=83=A8=E5=88=86=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account/tests.py | 2 +- contest/tests.py | 7 +++++++ contest_submission/tests.py | 5 +++++ problem/tests.py | 14 ++++++++++++++ submission/tests.py | 9 ++------- .../src/oj/submission/my_submissions_list.html | 2 +- 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/account/tests.py b/account/tests.py index f8cc9d06..3473c6c1 100644 --- a/account/tests.py +++ b/account/tests.py @@ -379,7 +379,7 @@ class UserLogoutTest(TestCase): user.set_password("1") user.save() - def logout_success(self): + def test_logout_success(self): self.client = Client() self.client.login(username="test", password="1") response = self.client.get("/logout/") diff --git a/contest/tests.py b/contest/tests.py index 2063c4e2..1605e028 100644 --- a/contest/tests.py +++ b/contest/tests.py @@ -568,6 +568,13 @@ class ContestListPageTest(TestCase): response = self.client.get('/contests/2/') self.assertTemplateUsed(response, "utils/error.html") + def test_query_by_keyword(self): + response = self.client.get(self.url + "?keyword=title1") + self.assertEqual(response.status_code, 200) + + def test_query_by_join_successfully(self): + response = self.client.get(self.url + "?join=True") + self.assertEqual(response.status_code, 200) diff --git a/contest_submission/tests.py b/contest_submission/tests.py index debd64bd..975d11ca 100644 --- a/contest_submission/tests.py +++ b/contest_submission/tests.py @@ -87,6 +87,11 @@ class ContestProblemMySubmissionListTest(TestCase): contest=self.global_contest, sort_index="a") + def test_contestsList_page_not_exist(self): + self.client.login(username="test1", password="testaa") + response = self.client.get('/contest/1/submissions/999/') + self.assertTemplateUsed(response, "utils/error.html") + class SubmissionAPITest(APITestCase): def setUp(self): diff --git a/problem/tests.py b/problem/tests.py index ab6d8985..63136958 100644 --- a/problem/tests.py +++ b/problem/tests.py @@ -187,5 +187,19 @@ class ProblemListPageTest(TestCase): hint="hint1", created_by=User.objects.get(username="test")) + def test_problemListPage_not_exist(self): + response = self.client.get('/problems/999/') + self.assertTemplateUsed(response, "utils/error.html") + def test_query_by_keyword(self): + response = self.client.get(self.url + "?keyword=title1") + self.assertEqual(response.status_code, 200) + + def test_query_by_tag_successfully(self): + response = self.client.get(self.url + "?tag=") + self.assertEqual(response.status_code, 200) + + def test_tag_does_not_exists(self): + response = self.client.get(self.url + "?tag=xxxxxx") + self.assertTemplateUsed(response, "utils/error.html") diff --git a/submission/tests.py b/submission/tests.py index 80fd1112..bb1d46de 100644 --- a/submission/tests.py +++ b/submission/tests.py @@ -150,12 +150,12 @@ class SubmissionAdminAPITest(APITestCase): memory_limit=1000, difficulty=1, hint="hint1", - created_by=User.objects.get(username="test1")) + created_by=self.user) self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, contest_type=2, show_rank=True, show_user_submission=True, start_time="2015-08-15T10:00:00.000Z", end_time="2015-08-15T12:00:00.000Z", - password="aacc", created_by=User.objects.get(username="test1")) + password="aacc", created_by=self.user) self.submission = Submission.objects.create(user_id=self.user.id, language=1, @@ -166,11 +166,6 @@ class SubmissionAdminAPITest(APITestCase): response = self.client.get(self.url) self.assertEqual(response.data, {"code": 1, "data": u"参数错误"}) - def test_submission_successfully(self): - data = {"problem_id": self.problem.id} - response = self.client.get(self.url, data=data) - self.assertEqual(response.data["code"], 0) - class SubmissionPageTest(TestCase): # 单个题目的提交详情页 diff --git a/template/src/oj/submission/my_submissions_list.html b/template/src/oj/submission/my_submissions_list.html index 2ee5b685..41784302 100644 --- a/template/src/oj/submission/my_submissions_list.html +++ b/template/src/oj/submission/my_submissions_list.html @@ -41,7 +41,7 @@ {% for item in submissions %} - + {{ forloop.counter |add:start_id }} {{ item.create_time }} {{ item.result|translate_result }}