aboutsummaryrefslogtreecommitdiffstats
path: root/backend/routes/forms
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2024-07-09 18:56:25 +0100
committerGravatar Chris Lovering <[email protected]>2024-07-09 19:01:28 +0100
commitae2d6ccac9d3c4d5181347e016660216212b3035 (patch)
treef58690867087ca26c45670d34d100a83e2233c47 /backend/routes/forms
parentDocument timezone field in SCHEMA.md (diff)
Move unittest filtering to the Form.dict() function
Diffstat (limited to 'backend/routes/forms')
-rw-r--r--backend/routes/forms/form.py7
-rw-r--r--backend/routes/forms/unittesting.py13
2 files changed, 1 insertions, 19 deletions
diff --git a/backend/routes/forms/form.py b/backend/routes/forms/form.py
index 410102a..86bbf49 100644
--- a/backend/routes/forms/form.py
+++ b/backend/routes/forms/form.py
@@ -13,7 +13,6 @@ from backend import constants, discord
from backend.models import Form
from backend.route import Route
from backend.routes.forms.discover import AUTH_FORM
-from backend.routes.forms.unittesting import filter_unittests
from backend.validation import ErrorMessage, OkayResponse, api
PUBLIC_FORM_FEATURES = (constants.FormFeatures.OPEN, constants.FormFeatures.DISCOVERABLE)
@@ -57,11 +56,7 @@ class SingleForm(Route):
if not form:
return JSONResponse({"error": "not_found"}, status_code=404)
- form = Form(**form)
- if not admin:
- form = filter_unittests(form)
-
- return JSONResponse(form.dict(admin=admin))
+ return JSONResponse(Form(**form).dict(admin=admin))
@requires(["authenticated"])
@api.validate(
diff --git a/backend/routes/forms/unittesting.py b/backend/routes/forms/unittesting.py
index 3239d35..57c3a86 100644
--- a/backend/routes/forms/unittesting.py
+++ b/backend/routes/forms/unittesting.py
@@ -26,19 +26,6 @@ class UnittestResult(NamedTuple):
result: str
-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 question.data["unittests"] is not None:
- question.data["unittests"]["tests"] = len(question.data["unittests"]["tests"])
-
- return form
-
-
def _make_unit_code(units: dict[str, str]) -> str:
"""Compose a dict mapping unit names to their code into an actual class body."""
result = ""