add test case upload api

This commit is contained in:
virusdefender
2017-01-25 16:29:00 +08:00
parent e34da1ac33
commit 48f79ec504
13 changed files with 103 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
from utils.api.tests import APITestCase
from .models import ProblemTag
from .views.admin import TestCaseUploadAPI
class ProblemTagListAPITest(APITestCase):
@@ -10,3 +11,15 @@ class ProblemTagListAPITest(APITestCase):
resp = self.client.get(self.reverse("problem_tag_list_api"))
self.assertSuccess(resp)
self.assertEqual(resp.data["data"], ["name1", "name2"])
class TestCaseUploadAPITest(APITestCase):
def setUp(self):
self.api = TestCaseUploadAPI()
def test_filter_file_name(self):
self.assertEqual(self.api.filter_name_list(["1.in", "1.out", "2.in", ".DS_Store"], spj=False), ["1.in", "1.out"])
self.assertEqual(self.api.filter_name_list(["2.in", "2.out"], spj=False), [])
self.assertEqual(self.api.filter_name_list(["1.in", "1.out", "2.in"], spj=True), ["1.in", "2.in"])
self.assertEqual(self.api.filter_name_list(["2.in", "3.in"], spj=True), [])