Skip to content

Commit

Permalink
Fix UserContestAPITest
Browse files Browse the repository at this point in the history
- Problem Tag을 제대로 사용하여 테스트 코드를 작성한다.
  • Loading branch information
jimin9038 committed Apr 1, 2022
1 parent 5b22513 commit 6a412ff
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions backend/contest/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<p>test</p>", "input_description": "test",
"output_description": "test", "time_limit": 1000, "memory_limit": 256, "difficulty": "Level1",
Expand Down Expand Up @@ -41,18 +39,6 @@
"bank_filter": [],
"visible": True, "real_time_rank": True}

DEFAULT_PROBLEM_DATA = {"_id": "A-110", "title": "test", "description": "<p>test</p>", "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": "<p>test</p>", "source": "test"}

DEFAULT_SUBMISSION_DATA = {
"problem_id": "1",
"user_id": 1,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6a412ff

Please sign in to comment.