Browse Source

DIV-1158 - Fixed Test / step_completeness rules incorrect (a conditional target shouldn't need to be required)

pull/172/head
Michael Olund 5 years ago
parent
commit
6adbe25545
2 changed files with 10 additions and 12 deletions
  1. +7
    -7
      edivorce/apps/core/tests/test_step_completeness.py
  2. +3
    -5
      edivorce/apps/core/utils/user_response.py

+ 7
- 7
edivorce/apps/core/tests/test_step_completeness.py View File

@ -133,18 +133,18 @@ class StepCompletenessTestCase(TestCase):
# Few required questions with one checking question with hidden question not shown # Few required questions with one checking question with hidden question not shown
self.create_response('lived_in_bc_you', '11/11/1111') self.create_response('lived_in_bc_you', '11/11/1111')
self.assertEqual(self.check_completeness(step), False)
self.assertEqual(self.check_completeness(step), True)
# All required questions with one checking question with hidden question not shown # All required questions with one checking question with hidden question not shown
self.create_response('last_name_born_you', 'Jackson') self.create_response('last_name_born_you', 'Jackson')
self.assertEqual(self.check_completeness(step), False)
self.assertEqual(self.check_completeness(step), True)
UserResponse.objects.filter(question_id='lived_in_bc_you').update(value="Moved to B.C. on") UserResponse.objects.filter(question_id='lived_in_bc_you').update(value="Moved to B.C. on")
self.assertEqual(self.check_completeness(step), False) self.assertEqual(self.check_completeness(step), False)
# All required questions with one checking question with hidden question # All required questions with one checking question with hidden question
self.create_response('moved_to_bc_date_you', '12/12/1212') self.create_response('moved_to_bc_date_you', '12/12/1212')
self.assertEqual(self.check_completeness(step), False)
self.assertEqual(self.check_completeness(step), True)
# All required questions with two checking question with one hidden and one shown # All required questions with two checking question with one hidden and one shown
self.create_response('any_other_name_you', 'NO') self.create_response('any_other_name_you', 'NO')
@ -189,12 +189,12 @@ class StepCompletenessTestCase(TestCase):
self.create_response('last_name_born_spouse', 'Jackson') self.create_response('last_name_born_spouse', 'Jackson')
self.assertEqual(self.check_completeness(step), False) self.assertEqual(self.check_completeness(step), False)
# All required questions with one checking question with hidden question missing
UserResponse.objects.filter(question_id='any_other_name_spouse').update(value="YES")
self.assertEqual(self.check_completeness(step), False)
# All required questions with one checking question with hidden question # All required questions with one checking question with hidden question
self.create_response('lived_in_bc_spouse', 'Since birth') self.create_response('lived_in_bc_spouse', 'Since birth')
self.assertEqual(self.check_completeness(step), True)
# All required questions with one checking question with hidden question missing
UserResponse.objects.filter(question_id='any_other_name_spouse').update(value="YES")
self.assertEqual(self.check_completeness(step), False) self.assertEqual(self.check_completeness(step), False)
# All required questions with two checking question with one hidden and one shown # All required questions with two checking question with one hidden and one shown


+ 3
- 5
edivorce/apps/core/utils/user_response.py View File

@ -151,11 +151,9 @@ def _is_question_required(question, questions_dict, responses_by_key):
else: else:
return HIDDEN return HIDDEN
elif target in questions_dict: elif target in questions_dict:
target_question_requirement = _is_question_required(target, questions_dict, responses_by_key)
if target_question_requirement == REQUIRED:
target_response = responses_by_key.get(target)
if target_response and _condition_met(target_response, reveal_response):
return REQUIRED
target_response = responses_by_key.get(target)
if target_response and _condition_met(target_response, reveal_response):
return REQUIRED
return HIDDEN return HIDDEN
else: else:
raise KeyError(f"Invalid conditional target '{target}' for question '{question}'") raise KeyError(f"Invalid conditional target '{target}' for question '{question}'")


Loading…
Cancel
Save