Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyxform/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ class ErrorCode(Enum):
msg=(
"[row : {row}] On the 'survey' sheet, the 'parameters' value is invalid. "
"For the 'range' question type, the parameters 'tick_interval', 'placeholder', "
"and 'tick_labelset' are only supported for the appearances 'vertical', 'no-ticks' "
"and the default (empty) horizontal."
"and 'tick_labelset' are only supported for the appearances 'vertical', 'no-ticks', "
"'vertical no-ticks', and the default (empty) horizontal."
),
)
RANGE_009 = Detail(
Expand Down
10 changes: 3 additions & 7 deletions pyxform/validators/pyxform/question_types/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ def process_range_question_type(
:param choices: The choices data as `{list_name: [choice_items[options], ...]}`.
:return: The updated row.
"""
"""
Returns a new row that includes the Range parameters start, end and step.

Raises PyXFormError when invalid range parameters are used.
"""
pv.validate(parameters=parameters, accepted=co.ParametersRange, row_number=row_number)
if (
appearance
and appearance not in {"vertical", "no-ticks"}
and "vertical" not in appearance
and "no-ticks" not in appearance
and any(
k in parameters
for k in (
Expand All @@ -45,7 +41,6 @@ def process_range_question_type(
)
):
raise PyXFormError(ErrorCode.RANGE_008.value.format(row=row_number))
no_ticks_appearance = appearance and appearance == "no-ticks"

defaults = QUESTION_TYPE_DICT["range"][co.PARAMETERS]
# set defaults
Expand Down Expand Up @@ -136,6 +131,7 @@ def process_parameter(name: str) -> Decimal | None:
if tick_list is None:
raise PyXFormError(ErrorCode.RANGE_006.value.format(row=row_number))

no_ticks_appearance = appearance and "no-ticks" in appearance
no_ticks_labels = set()
for item in tick_list:
errored = False
Expand Down
4 changes: 2 additions & 2 deletions tests/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- RC003: parameter names may in lower case or in mixed case.
- RC004: parameter names and values must be separated by a single equals sign.
- RC005: parameter values must be numeric (or for 'tick_labelset', the choices).
- RC006: appearance parameters are only valid with default, 'vertical' or 'no-ticks' appearance.
- RC006: appearance parameters are only valid with default, 'vertical' or 'no-ticks' (or both) appearance.
- RC007: parameters may specify ranges that are positive, negative, ascending, or descending.
- parameter 'step':
- RS001: must not be zero.
Expand Down Expand Up @@ -672,7 +672,7 @@ def test_parameters_not_compatible_with_appearance__ok(self):
("placeholder=3", {"odk:placeholder": "3"}),
("tick_labelset=c1", {}),
)
cases = ("", "vertical", "no-ticks")
cases = ("", "vertical", "no-ticks", "no-ticks vertical", "vertical no-ticks")
for param, attr in params:
for appearance in cases:
with self.subTest((param, attr, appearance)):
Expand Down
Loading