Questions: add min-length to string/text type questions (#6488)

* Questions: add min-length to string/text type questions

* fix test
This commit is contained in:
Richard Schreiber
2026-08-25 09:37:37 +02:00
committed by GitHub
parent 4755e7af0e
commit 6d4aba6e3d
9 changed files with 47 additions and 4 deletions
+1
View File
@@ -2479,6 +2479,7 @@ TEST_QUESTION_RES = {
"valid_datetime_min": None,
"valid_datetime_max": None,
"valid_file_portrait": False,
"valid_string_length_min": None,
"valid_string_length_max": None,
"help_text": {"en": "This is an example question"},
"options": [
+4 -2
View File
@@ -2970,8 +2970,9 @@ class SeatingTestCase(TestCase):
@pytest.mark.django_db
@pytest.mark.parametrize("qtype,answer,expected", [
(Question.TYPE_STRING, "a", "a"),
(Question.TYPE_TEXT, "v", "v"),
(Question.TYPE_STRING, "aaa", "aaa"),
(Question.TYPE_STRING, "a", ValidationError),
(Question.TYPE_TEXT, "vvv", "vvv"),
(Question.TYPE_TEXT, "waaaaay tooooo long", ValidationError),
(Question.TYPE_NUMBER, "0.9", ValidationError),
(Question.TYPE_NUMBER, "1", Decimal("1")),
@@ -3025,6 +3026,7 @@ def test_question_answer_validation(qtype, answer, expected):
valid_datetime_max=datetime.datetime(2018, 1, 16, 16, 0, 0, tzinfo=tzoffset(None, 3600)),
valid_number_min=Decimal('1'),
valid_number_max=Decimal('100'),
valid_string_length_min=3,
valid_string_length_max=8,
)
if isinstance(expected, type) and issubclass(expected, Exception):