Browse Source

Fix tests

pull/172/head
ariannedee 5 years ago
parent
commit
42ac62821c
3 changed files with 26 additions and 7 deletions
  1. +2
    -0
      edivorce/apps/core/tests/test_logic.py
  2. +13
    -0
      edivorce/apps/core/tests/test_step_completeness.py
  3. +11
    -7
      edivorce/apps/core/utils/conditional_logic.py

+ 2
- 0
edivorce/apps/core/tests/test_logic.py View File

@ -57,6 +57,7 @@ class ConditionalLogicTestCase(TestCase):
# Has children, and marked YES to children of marriage in prequal
self.create_response('children_of_marriage', 'YES')
self.create_response('has_children_under_19', 'YES')
self.assertEqual(logic.get_num_children_living_with(self.questions_dict, 'Lives with you'), '1')
self.assertEqual(logic.get_num_children_living_with(self.questions_dict, 'Lives with spouse'), '2')
self.assertEqual(logic.get_num_children_living_with(self.questions_dict, 'Lives with both'), '3')
@ -70,6 +71,7 @@ class ConditionalLogicTestCase(TestCase):
self.assertFalse(logic.determine_shared_custody(self.questions_dict))
self.create_response('children_of_marriage', 'YES')
self.create_response('has_children_under_19', 'YES')
self.assertTrue(logic.determine_shared_custody(self.questions_dict))
children = [self.child_live_with_spouse, self.child_live_with_you]


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

@ -466,6 +466,7 @@ class ChildrenStepCompletenessTestCase(TestCase):
self.child_live_with_spouse = {"child_name": "Child with spouse", "child_birth_date": "Jan 4, 2009", "child_live_with": "Lives with spouse", "child_relationship_to_you": "Adopted child", "child_relationship_to_spouse": "Adopted child", "child_live_with_other_details": ""}
self.child_live_with_both = {"child_name": "Child with both", "child_birth_date": "Jan 4, 2009", "child_live_with": "Lives with both", "child_relationship_to_you": "Adopted child", "child_relationship_to_spouse": "Adopted child", "child_live_with_other_details": ""}
self.create_response('children_of_marriage', 'YES')
self.create_response('has_children_under_19', 'YES')
def get_children_step_status(self, substep=None):
responses_dict = get_data_for_user(self.user)
@ -506,6 +507,18 @@ class ChildrenStepCompletenessTestCase(TestCase):
self.assertEqual(self.get_children_step_status('payor_medical'), 'Hidden')
self.assertEqual(self.get_children_step_status('what_for'), 'Hidden')
def test_only_grown_children(self):
self.create_response('children_of_marriage', 'YES')
self.create_response('has_children_under_19', 'NO')
self.create_response('has_children_over_19', 'YES')
self.create_response('children_financial_support', '["NO"]')
self.assertEqual(self.get_children_step_status(), 'Hidden')
self.assertEqual(self.get_children_step_status('your_children'), 'Hidden')
self.assertEqual(self.get_children_step_status('income_expenses'), 'Hidden')
self.assertEqual(self.get_children_step_status('facts'), 'Hidden')
self.assertEqual(self.get_children_step_status('payor_medical'), 'Hidden')
self.assertEqual(self.get_children_step_status('what_for'), 'Hidden')
def test_children_details(self):
substep = 'your_children'


+ 11
- 7
edivorce/apps/core/utils/conditional_logic.py View File

@ -3,23 +3,23 @@ import json
import re
def determine_has_children_of_marriage(questions_dict):
has_children = questions_dict.get('children_of_marriage', '') == 'YES'
has_under_19 = questions_dict.get('has_children_under_19', '') == 'YES'
return has_children and (has_under_19 or _children_over_19_supported(questions_dict))
def if_no_children(return_val):
def decorator_no_children(func):
@functools.wraps(func)
def inner(questions_dict, *args, **kwargs):
if questions_dict.get('children_of_marriage', '') != 'YES':
if not determine_has_children_of_marriage(questions_dict):
return return_val
return func(questions_dict, *args, **kwargs)
return inner
return decorator_no_children
@if_no_children(return_val=False)
def determine_has_children_of_marriage(questions_dict):
has_under_19 = questions_dict.get('has_children_under_19', '') == 'YES'
return has_under_19 or determine_child_over_19_supported(questions_dict)
@if_no_children(return_val=[])
def get_children(questions_dict):
children_json = questions_dict.get('claimant_children', '[]')
@ -71,6 +71,10 @@ def determine_split_custody(questions_dict):
@if_no_children(return_val=False)
def determine_child_over_19_supported(questions_dict):
return _children_over_19_supported(questions_dict)
def _children_over_19_supported(questions_dict):
has_children_over_19 = questions_dict.get('has_children_over_19', '') == 'YES'
support = json.loads(questions_dict.get('children_financial_support', '[]'))
supporting_children = len(support) > 0 and 'NO' not in support


Loading…
Cancel
Save