mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-01 10:02:01 +00:00
Fix tests.
This commit is contained in:
parent
d221619565
commit
a96a23da2d
@ -17,7 +17,9 @@ class ProblemTagListAPITest(APITestCase):
|
||||
ProblemTag.objects.create(name="name2")
|
||||
resp = self.client.get(self.reverse("problem_tag_list_api"))
|
||||
self.assertSuccess(resp)
|
||||
self.assertEqual(resp.data["data"], ["name1", "name2"])
|
||||
resp_data = resp.data['data']
|
||||
self.assertEqual(resp_data[0]["name"], "name1")
|
||||
self.assertEqual(resp_data[1]["name"], "name2")
|
||||
|
||||
|
||||
class TestCaseUploadAPITest(APITestCase):
|
||||
@ -76,9 +78,9 @@ class TestCaseUploadAPITest(APITestCase):
|
||||
self.assertEqual(f.read(), name + "\n" + name + "\n" + "end")
|
||||
|
||||
|
||||
class ProblemAPITest(APITestCase):
|
||||
class ProblemAdminAPITest(APITestCase):
|
||||
def setUp(self):
|
||||
self.url = self.reverse("problem_api")
|
||||
self.url = self.reverse("problem_admin_api")
|
||||
self.create_super_admin()
|
||||
self.data = {"_id": "A-110", "title": "test", "description": "<p>test</p>", "input_description": "test",
|
||||
"output_description": "test", "time_limit": 1000, "memory_limit": 256, "difficulty": "Low",
|
||||
|
@ -4,6 +4,6 @@ from ..views.admin import ContestProblemAPI, ProblemAPI, TestCaseUploadAPI
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^test_case/upload/?$", TestCaseUploadAPI.as_view(), name="test_case_upload_api"),
|
||||
url(r"^problem/?$", ProblemAPI.as_view(), name="problem_api"),
|
||||
url(r"^problem/?$", ProblemAPI.as_view(), name="problem_admin_api"),
|
||||
url(r"^contest/problem/?$", ContestProblemAPI.as_view(), name="contest_problem_api")
|
||||
]
|
||||
|
@ -7,9 +7,7 @@ from ..serializers import ProblemSerializer, TagSerializer
|
||||
|
||||
class ProblemTagAPI(APIView):
|
||||
def get(self, request):
|
||||
tags = ProblemTag.objects.annotate(problem_number=Count("problem"))\
|
||||
.filter(problem_number__gt=0).order_by("-problem_number")
|
||||
return self.success(TagSerializer(tags, many=True).data)
|
||||
return self.success(TagSerializer(ProblemTag.objects.all(), many=True).data)
|
||||
|
||||
|
||||
class ProblemAPI(APIView):
|
||||
|
Loading…
Reference in New Issue
Block a user