From 6adbe25545e25a1b1b53aca1ed9dc0d4aaabbdd1 Mon Sep 17 00:00:00 2001 From: Michael Olund Date: Thu, 5 Nov 2020 11:28:00 -0800 Subject: [PATCH] DIV-1158 - Fixed Test / step_completeness rules incorrect (a conditional target shouldn't need to be required) --- edivorce/apps/core/tests/test_step_completeness.py | 14 +++++++------- edivorce/apps/core/utils/user_response.py | 8 +++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/edivorce/apps/core/tests/test_step_completeness.py b/edivorce/apps/core/tests/test_step_completeness.py index a668ea21..43300358 100644 --- a/edivorce/apps/core/tests/test_step_completeness.py +++ b/edivorce/apps/core/tests/test_step_completeness.py @@ -133,18 +133,18 @@ class StepCompletenessTestCase(TestCase): # Few required questions with one checking question with hidden question not shown 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 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") self.assertEqual(self.check_completeness(step), False) # All required questions with one checking question with hidden question 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 self.create_response('any_other_name_you', 'NO') @@ -189,12 +189,12 @@ class StepCompletenessTestCase(TestCase): self.create_response('last_name_born_spouse', 'Jackson') 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 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) # All required questions with two checking question with one hidden and one shown diff --git a/edivorce/apps/core/utils/user_response.py b/edivorce/apps/core/utils/user_response.py index 1cfa700c..a280f8ca 100644 --- a/edivorce/apps/core/utils/user_response.py +++ b/edivorce/apps/core/utils/user_response.py @@ -151,11 +151,9 @@ def _is_question_required(question, questions_dict, responses_by_key): else: return HIDDEN 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 else: raise KeyError(f"Invalid conditional target '{target}' for question '{question}'")