From 648adc5b5ef6c8d8e6ea811e89e9d08afe949c28 Mon Sep 17 00:00:00 2001 From: Samuele Mattiuzzo Date: Thu, 7 Mar 2019 11:23:27 +0000 Subject: [PATCH] (2.03) Render 'condition' when present in atleast_one rule #156 --- iatirulesets/text.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/iatirulesets/text.py b/iatirulesets/text.py index 06beb128..024d9cb0 100644 --- a/iatirulesets/text.py +++ b/iatirulesets/text.py @@ -28,11 +28,15 @@ def rules_text(rules, reduced_path, show_all=False): out.append('``{0}`` must not be present if ``{1}`` are present.'.format(case_path, human_list(other_paths))) break elif rule == 'atleast_one': + cond = case.get('condition', None) + cond = '.' if not cond else ' if {}'.format(cond) + if other_paths: - out.append('Either ``{0}`` or ``{1}`` must be present.'.format(case_path, human_list(other_paths))) + out.append('Either ``{0}`` or ``{1}`` must be present{2}'.format(case_path, human_list(other_paths), cond)) break else: - out.append('``{0}`` must be present.'.format(case_path)) + out.append('``{0}`` must be present{1}'.format(case_path, cond)) + elif rule == 'only_one_of': out.append('``{0}`` must not be present alongisde ``{1}``.'.format(case_path, human_list(case['excluded'], 'and'))) elif rule == 'startswith':