diff --git a/backend/contest/tests.py b/backend/contest/tests.py index 2ccc89b26..0efae5502 100644 --- a/backend/contest/tests.py +++ b/backend/contest/tests.py @@ -8,9 +8,7 @@ from .models import ContestAnnouncement, ContestRuleType, Contest, ACMContestRank from submission.models import Submission -from problem.models import Problem, ProblemIOMode - -from problem.models import ProblemIOMode +from problem.models import Problem, ProblemIOMode, ProblemTag DEFAULT_PROBLEM_DATA = {"_id": "A-110", "title": "test", "description": "

test

", "input_description": "test", "output_description": "test", "time_limit": 1000, "memory_limit": 256, "difficulty": "Level1", @@ -41,18 +39,6 @@ "bank_filter": [], "visible": True, "real_time_rank": True} -DEFAULT_PROBLEM_DATA = {"_id": "A-110", "title": "test", "description": "

test

", "input_description": "test", - "output_description": "test", "time_limit": 1000, "memory_limit": 256, "difficulty": "Level1", - "visible": True, "languages": ["C", "C++", "Java", "Python2"], "template": {}, - "samples": [{"input": "test", "output": "test"}], "spj": False, "spj_language": "C", - "spj_code": "", "spj_compile_ok": True, "test_case_id": "499b26290cc7994e0b497212e842ea85", - "test_case_score": [{"output_name": "1.out", "input_name": "1.in", "output_size": 0, - "stripped_output_md5": "d41d8cd98f00b204e9800998ecf8427e", - "input_size": 0, "score": 0}], - "io_mode": {"io_mode": ProblemIOMode.standard, "input": "input.txt", "output": "output.txt"}, - "share_submission": False, - "rule_type": "ACM", "hint": "

test

", "source": "test"} - DEFAULT_SUBMISSION_DATA = { "problem_id": "1", "user_id": 1, @@ -292,8 +278,17 @@ def setUp(self): # create problem in contest data = copy.deepcopy(DEFAULT_PROBLEM_DATA) data["contest_id"] = self.contest.id - self.problem = Problem.objects.create(created_by=admin, **data) + tags = data.pop("tags") + problem = Problem.objects.create(created_by=admin, **data) + + for item in tags: + try: + tag = ProblemTag.objects.get(name=item) + except ProblemTag.DoesNotExist: + tag = ProblemTag.objects.create(name=item) + problem.tags.add(tag) + self.problem = problem # user submit problem user = self.create_user("test", "test123") data = copy.deepcopy(DEFAULT_SUBMISSION_DATA)