diff --git a/pyxform/errors.py b/pyxform/errors.py index d02cb4bb..f8c71c29 100644 --- a/pyxform/errors.py +++ b/pyxform/errors.py @@ -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( diff --git a/pyxform/validators/pyxform/question_types/range.py b/pyxform/validators/pyxform/question_types/range.py index 1c346e7d..e8e22597 100644 --- a/pyxform/validators/pyxform/question_types/range.py +++ b/pyxform/validators/pyxform/question_types/range.py @@ -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 ( @@ -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 @@ -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 diff --git a/tests/test_range.py b/tests/test_range.py index 20d17333..0f0b74b7 100644 --- a/tests/test_range.py +++ b/tests/test_range.py @@ -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. @@ -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)):