mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-09-21 08:23:20 +00:00
完善部分测试
This commit is contained in:
parent
a216f8e1ea
commit
2252107a80
@ -379,7 +379,7 @@ class UserLogoutTest(TestCase):
|
|||||||
user.set_password("1")
|
user.set_password("1")
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
def logout_success(self):
|
def test_logout_success(self):
|
||||||
self.client = Client()
|
self.client = Client()
|
||||||
self.client.login(username="test", password="1")
|
self.client.login(username="test", password="1")
|
||||||
response = self.client.get("/logout/")
|
response = self.client.get("/logout/")
|
||||||
|
@ -568,6 +568,13 @@ class ContestListPageTest(TestCase):
|
|||||||
response = self.client.get('/contests/2/')
|
response = self.client.get('/contests/2/')
|
||||||
self.assertTemplateUsed(response, "utils/error.html")
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,6 +87,11 @@ class ContestProblemMySubmissionListTest(TestCase):
|
|||||||
contest=self.global_contest,
|
contest=self.global_contest,
|
||||||
sort_index="a")
|
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):
|
class SubmissionAPITest(APITestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -187,5 +187,19 @@ class ProblemListPageTest(TestCase):
|
|||||||
hint="hint1",
|
hint="hint1",
|
||||||
created_by=User.objects.get(username="test"))
|
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")
|
||||||
|
|
||||||
|
@ -150,12 +150,12 @@ class SubmissionAdminAPITest(APITestCase):
|
|||||||
memory_limit=1000,
|
memory_limit=1000,
|
||||||
difficulty=1,
|
difficulty=1,
|
||||||
hint="hint1",
|
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,
|
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
|
||||||
contest_type=2, show_rank=True, show_user_submission=True,
|
contest_type=2, show_rank=True, show_user_submission=True,
|
||||||
start_time="2015-08-15T10:00:00.000Z",
|
start_time="2015-08-15T10:00:00.000Z",
|
||||||
end_time="2015-08-15T12: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,
|
self.submission = Submission.objects.create(user_id=self.user.id,
|
||||||
language=1,
|
language=1,
|
||||||
@ -166,11 +166,6 @@ class SubmissionAdminAPITest(APITestCase):
|
|||||||
response = self.client.get(self.url)
|
response = self.client.get(self.url)
|
||||||
self.assertEqual(response.data, {"code": 1, "data": u"参数错误"})
|
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):
|
class SubmissionPageTest(TestCase):
|
||||||
# 单个题目的提交详情页
|
# 单个题目的提交详情页
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for item in submissions %}
|
{% for item in submissions %}
|
||||||
<tr class="{{ item.result|translate_result_class }}">
|
<tr class="{{ item.result|translate_result_class }}">
|
||||||
<th scope="row"><a href="/my_submission/{{ item.id }}/" id="id_{{ forloop.counter }}">
|
<th scope="row"><a href="/submission/{{ item.id }}/" id="id_{{ forloop.counter }}">
|
||||||
{{ forloop.counter |add:start_id }}</a></th>
|
{{ forloop.counter |add:start_id }}</a></th>
|
||||||
<td>{{ item.create_time }}</td>
|
<td>{{ item.create_time }}</td>
|
||||||
<td>{{ item.result|translate_result }}</td>
|
<td>{{ item.result|translate_result }}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user