diff options
author | 2021-02-24 14:57:00 +0100 | |
---|---|---|
committer | 2021-02-24 14:57:37 +0100 | |
commit | 6a1be658fd7fea03428f0ef1bbcce630ab290782 (patch) | |
tree | 0c805fc902088bce0a94734adf4e35d872ffc622 /backend/routes/forms/unittesting.py | |
parent | Add support for hidden tests (diff) |
Censor unittests on GET /forms/$id
Diffstat (limited to 'backend/routes/forms/unittesting.py')
-rw-r--r-- | backend/routes/forms/unittesting.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/backend/routes/forms/unittesting.py b/backend/routes/forms/unittesting.py index ddf0843..0cb7d8d 100644 --- a/backend/routes/forms/unittesting.py +++ b/backend/routes/forms/unittesting.py @@ -16,6 +16,19 @@ with open("resources/unittest_template.py") as file: UnittestResult = namedtuple("UnittestResult", "question_id return_code passed result") +def filter_unittests(form: Form) -> Form: + """ + Replace the unittest data section of code questions with the number of test cases. + + This is used to redact the exact tests when sending the form back to the frontend. + """ + for question in form.questions: + if question.type == "code" and "unittests" in question.data: + question.data["unittests"] = len(question.data["unittests"]) + + return form + + def _make_unit_code(units: dict[str, str]) -> str: result = "" |