Browse Source

Merge pull request #137 from bcgov/DIV-1179

DIV-1179: Fix some Children conditional logic
pull/172/head
Arianne 5 years ago
committed by GitHub
parent
commit
7f11d753e4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 144 additions and 63 deletions
  1. +36
    -33
      edivorce/apps/core/templates/pdf/form1.html
  2. +2
    -2
      edivorce/apps/core/templates/pdf/form37.html
  3. +1
    -1
      edivorce/apps/core/templates/pdf/form38.html
  4. +2
    -2
      edivorce/apps/core/templates/pdf/form52.html
  5. +1
    -7
      edivorce/apps/core/templates/question/06_children_what_for.html
  6. +15
    -3
      edivorce/apps/core/templatetags/format_utils.py
  7. +13
    -15
      edivorce/apps/core/templatetags/step_order.py
  8. +74
    -0
      edivorce/apps/core/tests/test_logic.py

+ 36
- 33
edivorce/apps/core/templates/pdf/form1.html View File

@ -364,7 +364,7 @@
<td> <td>
<strong>Children:</strong> <strong>Children:</strong>
<br><br> <br><br>
<span class="td-list-item">{% checkbox children_of_marriage='NO' %}</span>
<span class="td-list-item">{% checkbox has_children_of_marriage='False' %}</span>
<div class="td-list-text"> <div class="td-list-text">
There are no children of the marriage, as defined by There are no children of the marriage, as defined by
the <em>Divorce Act</em> (Canada), or children of whom the <em>Divorce Act</em> (Canada), or children of whom
@ -372,7 +372,7 @@
of the <em>Family Law Act</em>. of the <em>Family Law Act</em>.
</div> </div>
<br><strong>OR</strong><br><br> <br><strong>OR</strong><br><br>
<span class="td-list-item">{% checkbox children_of_marriage='YES' %}</span>
<span class="td-list-item">{% checkbox derived.has_children_of_marriage %}</span>
<div class="td-list-text"> <div class="td-list-text">
There are children of the marriage, as defined by the There are children of the marriage, as defined by the
<em>Divorce Act</em> (Canada), or children of whom <em>Divorce Act</em> (Canada), or children of whom
@ -385,8 +385,8 @@
<th align="center">Full name</th> <th align="center">Full name</th>
<th align="center">Birth date<br />[<em>dd/mmm/yyyy</em>]</th> <th align="center">Birth date<br />[<em>dd/mmm/yyyy</em>]</th>
<th align="center">Resides with</th> <th align="center">Resides with</th>
</tr
{% if responses.children_of_marriage == 'YES' %}
</tr>
{% if derived.has_children_of_marriage %}
{% for child in responses.children %} {% for child in responses.children %}
<tr> <tr>
<td align="center">{{ child.child_name }}</td> <td align="center">{{ child.child_name }}</td>
@ -418,14 +418,14 @@
<tr> <tr>
<td colname="c2"> <td colname="c2">
<span class="td-list-item"> <span class="td-list-item">
A. {% checkbox want_parenting_arrangements='YES' children_of_marriage='YES' want_which_orders='Child support' %}
A. {% checkbox derived.has_children_of_marriage derived.wants_child_support want_parenting_arrangements='YES' %}
</span> </span>
<div class="td-list-text"> <div class="td-list-text">
Claimant 1 and Claimant 2 are asking for the following Claimant 1 and Claimant 2 are asking for the following
order respecting arrangements for parenting or order respecting arrangements for parenting or
contact: contact:
<span class="form-entry form-textarea not-complete form-list-textarea"> <span class="form-entry form-textarea not-complete form-list-textarea">
{% if responses.children_of_marriage == 'YES' and responses.want_parenting_arrangements == 'YES' and responses.order_respecting_arrangement and 'Child support' in responses.want_which_orders %}
{% if derived.has_children_of_marriage and responses.want_parenting_arrangements == 'YES' and responses.order_respecting_arrangement and derived.wants_child_support %}
<ul>{{ responses.order_respecting_arrangement|striptags|linebreaksli }}</ul> <ul>{{ responses.order_respecting_arrangement|striptags|linebreaksli }}</ul>
{% endif %} {% endif %}
</span> </span>
@ -435,18 +435,18 @@
<tr> <tr>
<td colname="c2"> <td colname="c2">
<span class="td-list-item"> <span class="td-list-item">
B.
B.
{% if responses.child_support_in_order == 'NO' %} {% if responses.child_support_in_order == 'NO' %}
{% checkbox false %} {% checkbox false %}
{% else %} {% else %}
{% checkbox responses.order_for_child_support children_of_marriage='YES' want_which_orders='Child support' %}
{% checkbox responses.order_for_child_support derived.has_children_of_marriage derived.wants_child_support %}
{% endif %} {% endif %}
</span> </span>
<div class="td-list-text"> <div class="td-list-text">
Claimant 1 and Claimant 2 are asking for an order for Claimant 1 and Claimant 2 are asking for an order for
child support as follows: child support as follows:
<span class="form-entry form-textarea not-complete form-list-textarea"> <span class="form-entry form-textarea not-complete form-list-textarea">
{% if responses.children_of_marriage == 'YES' and responses.order_for_child_support and 'Child support' in responses.want_which_orders and responses.child_support_in_order != 'NO' %}
{% if derived.has_children_of_marriage and responses.order_for_child_support and derived.wants_child_support and responses.child_support_in_order != 'NO' %}
<ul>{{ responses.order_for_child_support|striptags|linebreaksli }}</ul> <ul>{{ responses.order_for_child_support|striptags|linebreaksli }}</ul>
{% endif %} {% endif %}
</span> </span>
@ -456,12 +456,12 @@
<tr> <tr>
<td colname="c2"> <td colname="c2">
<span class="td-list-item"> <span class="td-list-item">
C. {% checkbox responses.describe_order_special_extra_expenses children_of_marriage='YES' want_which_orders='Child support' special_extraordinary_expenses='YES' %}
C. {% checkbox derived.wants_child_support derived.has_children_of_marriage special_extraordinary_expenses='YES' %}
</span> </span>
<div class="td-list-text"> <div class="td-list-text">
Claimant 1 and Claimant 2 are asking for an order for Special and Extraordinary Expenses as follows:<br> Claimant 1 and Claimant 2 are asking for an order for Special and Extraordinary Expenses as follows:<br>
<span class="form-entry form-textarea not-complete form-list-textarea"> <span class="form-entry form-textarea not-complete form-list-textarea">
{% if responses.children_of_marriage == 'YES' and responses.special_extraordinary_expenses == 'YES' and 'Child support' in responses.want_which_orders %}
{% if derived.has_children_of_marriage and responses.special_extraordinary_expenses == 'YES' and derived.wants_child_support %}
<ul>{{ responses.describe_order_special_extra_expenses|striptags|linebreaksli }}</ul> <ul>{{ responses.describe_order_special_extra_expenses|striptags|linebreaksli }}</ul>
{% endif %} {% endif %}
</span> </span>
@ -472,7 +472,7 @@
<tr> <tr>
<td colname="c2"> <td colname="c2">
<span class="td-list-item"> <span class="td-list-item">
D. {% checkbox responses.child_support_act children_of_marriage='YES' want_which_orders='Child support' %}
D. {% checkbox responses.child_support_act derived.has_children_of_marriage derived.wants_child_support %}
</span> </span>
<div class="td-list-text"> <div class="td-list-text">
Claimant 1 and Claimant 2 are asking for the orders Claimant 1 and Claimant 2 are asking for the orders
@ -480,10 +480,10 @@
following statute(s):<br> following statute(s):<br>
[<em>Check one or both of the following boxes, as [<em>Check one or both of the following boxes, as
applicable.</em>]<br><br> applicable.</em>]<br><br>
{% checkbox child_support_act='the Divorce Act (Canada)' children_of_marriage='YES' want_which_orders='Child support' %}
{% checkbox derived.has_children_of_marriage derived.wants_child_support child_support_act='the Divorce Act (Canada)' %}
the <em>Divorce Act</em> (Canada) the <em>Divorce Act</em> (Canada)
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
{% checkbox child_support_act='the Family Law Act' children_of_marriage='YES' want_which_orders='Child support' %}
{% checkbox derived.has_children_of_marriage derived.wants_child_support child_support_act='the Family Law Act' %}
the <em>Family Law Act</em> the <em>Family Law Act</em>
</div> </div>
</td> </td>
@ -496,11 +496,11 @@
<tbody> <tbody>
<tr> <tr>
<td colname="c2"> <td colname="c2">
<span class="td-list-item">{% checkbox want_which_orders='Spousal support' %}</span>
<span class="td-list-item">{% checkbox derived.wants_spousal_support %}</span>
<div class="td-list-text"> <div class="td-list-text">
Claimant 1 and Claimant 2 are asking for an order for spousal support as follows:<br> Claimant 1 and Claimant 2 are asking for an order for spousal support as follows:<br>
<span class="form-entry form-textarea not-complete"> <span class="form-entry form-textarea not-complete">
{% if 'Spousal support' in responses.want_which_orders and responses.spouse_support_details %}
{% if derived.wants_spousal_support and responses.spouse_support_details %}
<ul>{{responses.spouse_support_details|striptags|linebreaksli }}</ul> <ul>{{responses.spouse_support_details|striptags|linebreaksli }}</ul>
{% endif %} {% endif %}
</span> </span>
@ -510,16 +510,16 @@
<tr> <tr>
<td colname="c2"> <td colname="c2">
<span class="td-list-item"> <span class="td-list-item">
{% checkbox responses.spouse_support_act want_which_orders='Spousal support' %}
{% checkbox responses.spouse_support_act derived.wants_spousal_support %}
</span> </span>
<div class="td-list-text"> <div class="td-list-text">
Claimant 1 and Claimant 2 are asking for an order for spousal support under:<br> Claimant 1 and Claimant 2 are asking for an order for spousal support under:<br>
[<em>Check one or both of the following boxes, as applicable.</em>] [<em>Check one or both of the following boxes, as applicable.</em>]
<br><br> <br><br>
{% checkbox want_which_orders='Spousal support' spouse_support_act='The Divorce Act (Canada)' %}
{% checkbox derived.wants_spousal_support spouse_support_act='The Divorce Act (Canada)' %}
the <em> Divorce Act </em> (Canada) the <em> Divorce Act </em> (Canada)
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
{% checkbox want_which_orders='Spousal support' spouse_support_act='The Family Law Act' %}
{% checkbox derived.wants_spousal_support spouse_support_act='The Family Law Act' %}
the <em> Family Law Act </em> the <em> Family Law Act </em>
</div> </div>
@ -535,13 +535,13 @@
<td> <td>
<div><strong>A. Property claims under the <em>Family Law Act</em></strong><br><br></div> <div><strong>A. Property claims under the <em>Family Law Act</em></strong><br><br></div>
<span class="td-list-item"> <span class="td-list-item">
{% checkbox want_which_orders='Division of property and debts' %}
{% checkbox derived.wants_property_division %}
</span> </span>
<div class="td-list-text"> <div class="td-list-text">
Claimant 1 and Claimant 2 are asking for an order for:<br><br> Claimant 1 and Claimant 2 are asking for an order for:<br><br>
<div> <div>
<span class="td-list-item"> <span class="td-list-item">
{% checkbox want_which_orders='Division of property and debts' deal_with_property_debt='Equal division' %}
{% checkbox derived.wants_property_division deal_with_property_debt='Equal division' %}
</span> </span>
<div class="td-list-text"> <div class="td-list-text">
an equal division of family property and family debt<br><br> an equal division of family property and family debt<br><br>
@ -549,12 +549,12 @@
</div> </div>
<div> <div>
<span class="td-list-item"> <span class="td-list-item">
{% checkbox want_which_orders='Division of property and debts' deal_with_property_debt='Unequal division' %}
{% checkbox derived.wants_property_division deal_with_property_debt='Unequal division' %}
</span> </span>
<div class="td-list-text"> <div class="td-list-text">
an unequal division of family property and family debt as follows: an unequal division of family property and family debt as follows:
<span class="form-entry form-textarea not-complete"> <span class="form-entry form-textarea not-complete">
{% if responses.deal_with_property_debt == 'Unequal division' and responses.how_to_divide_property_debt and 'Division of property and debts' in responses.want_which_orders %}
{% if derived.wants_property_division and responses.deal_with_property_debt == 'Unequal division' and responses.how_to_divide_property_debt %}
<ul>{{ responses.how_to_divide_property_debt|striptags|linebreaksli }}</ul> <ul>{{ responses.how_to_divide_property_debt|striptags|linebreaksli }}</ul>
{% endif %} {% endif %}
</span> </span>
@ -566,13 +566,13 @@
<tr> <tr>
<td> <td>
<div><strong>B. Other property claims</strong><br><br></div> <div><strong>B. Other property claims</strong><br><br></div>
<span class="td-list-item">{% checkbox responses.other_property_claims %}</span>
<span class="td-list-item">{% checkbox derived.wants_property_division responses.other_property_claims %}</span>
<div class="td-list-text"> <div class="td-list-text">
Claimant 1 and Claimant 2 ask for an order respecting Claimant 1 and Claimant 2 ask for an order respecting
an interest in property or for compensation instead an interest in property or for compensation instead
of an interest in that property, as follows:<br> of an interest in that property, as follows:<br>
<span class="form-entry form-textarea not-complete"> <span class="form-entry form-textarea not-complete">
{% if responses.other_property_claims %}
{% if derived.wants_property_division and responses.other_property_claims %}
<ul>{{ responses.other_property_claims|striptags|linebreaksli }}</ul> <ul>{{ responses.other_property_claims|striptags|linebreaksli }}</ul>
{% endif %} {% endif %}
</span> </span>
@ -586,14 +586,17 @@
<table class="table table-bordered table-fixed"> <table class="table table-bordered table-fixed">
<tbody> <tbody>
<tr> <tr>
{% check_list source=responses.want_which_orders value='Other orders' as order_wanted %}
<td> <td>
<span class="td-list-item"> <span class="td-list-item">
{% if order_wanted and responses.other_orders_detail or responses.name_change_you == 'YES' or responses.name_change_spouse == 'YES' %}
{% checkbox %}
{% else %}
{% if derived.wants_other_orders %}
{% if responses.other_orders_detail or responses.name_change_you == 'YES' or responses.name_change_spouse == 'YES' %}
{% checkbox %}
{% else %}
{% checkbox False %}
{% endif %}
{% else %}
{% checkbox False %} {% checkbox False %}
{% endif %}
{% endif %}
</span> </span>
<div class="td-list-text"> <div class="td-list-text">
Claimant 1 and Claimant 2 are asking for an order in the Claimant 1 and Claimant 2 are asking for an order in the
@ -601,11 +604,11 @@
<span class="form-entry form-textarea not-complete"> <span class="form-entry form-textarea not-complete">
<ul> <ul>
{% if responses.other_orders_detail and order_wanted %}
{% if derived.wants_other_orders and responses.other_orders_detail %}
{{ responses.other_orders_detail|striptags|linebreaksli }} {{ responses.other_orders_detail|striptags|linebreaksli }}
{% endif %} {% endif %}
{% if responses.name_change_you == 'YES' %}
{% if derived.wants_other_orders and responses.name_change_you == 'YES' %}
<li> <li>
Pursuant to Section 5 of the Name Act, Claimant 1 shall Pursuant to Section 5 of the Name Act, Claimant 1 shall
bear the name of {{ responses.name_change_you_fullname }} bear the name of {{ responses.name_change_you_fullname }}
@ -613,7 +616,7 @@
</li> </li>
{% endif %} {% endif %}
{% if responses.name_change_spouse == 'YES' %}
{% if derived.wants_other_orders and responses.name_change_spouse == 'YES' %}
<li> <li>
Pursuant to Section 5 of the Name Act, Claimant 2 shall Pursuant to Section 5 of the Name Act, Claimant 2 shall
bear the name of {{ responses.name_change_spouse_fullname }} bear the name of {{ responses.name_change_spouse_fullname }}


+ 2
- 2
edivorce/apps/core/templates/pdf/form37.html View File

@ -278,9 +278,9 @@
out in the proposed order for the expenses under section 7 of the out in the proposed order for the expenses under section 7 of the
Guidelines is Guidelines is
{{ derived.total_section_seven_expenses|money }}. {{ derived.total_section_seven_expenses|money }}.
Claimant 1's proportionate share is
Claimant 1's proportionate share is
{{ derived.claimant_1_share|money }}. {{ derived.claimant_1_share|money }}.
Claimant 2's proportionate share is
Claimant 2's proportionate share is
{{ derived.claimant_2_share|money }}. {{ derived.claimant_2_share|money }}.
{% endif %} {% endif %}
</li> </li>


+ 1
- 1
edivorce/apps/core/templates/pdf/form38.html View File

@ -174,7 +174,7 @@
</li> </li>
<li> <li>
{% if responses.children_of_marriage == 'YES' %}
{% if derived.has_children_of_marriage %}
<p> <p>
There are children of the marriage as defined by There are children of the marriage as defined by
{{ derived.child_support_acts }}, and {{ derived.child_support_acts }}, and


+ 2
- 2
edivorce/apps/core/templates/pdf/form52.html View File

@ -110,7 +110,7 @@
</li> </li>
{% endif %} {% endif %}
{% if responses.children_of_marriage == 'YES' and derived.wants_child_support %}
{% if derived.has_children_of_marriage and derived.wants_child_support %}
{% for order in derived.pursuant_parenting_arrangement %} {% for order in derived.pursuant_parenting_arrangement %}
<li>{{ order }}</li> <li>{{ order }}</li>
{% endfor %} {% endfor %}
@ -121,7 +121,7 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if responses.children_of_marriage == 'YES' and responses.special_extraordinary_expenses == 'YES' %}
{% if derived.has_children_of_marriage and responses.special_extraordinary_expenses == 'YES' %}
{{ responses.describe_order_special_extra_expenses|striptags|linebreaksli }} {{ responses.describe_order_special_extra_expenses|striptags|linebreaksli }}
{% endif %} {% endif %}


+ 1
- 7
edivorce/apps/core/templates/question/06_children_what_for.html View File

@ -367,7 +367,7 @@
</blockquote> </blockquote>
{% input_field type="textarea" name="order_respecting_arrangement" class="response-textarea form-control" maxlength="20000" rows="7"%} {% input_field type="textarea" name="order_respecting_arrangement" class="response-textarea form-control" maxlength="20000" rows="7"%}
</div> </div>
{% if 'Child support' in want_which_orders|load_json %}
{% if derived.wants_child_support %}
<div class="question-well {% if order_for_child_support_error %}error{% endif %}" id="child_support_description"> <div class="question-well {% if order_for_child_support_error %}error{% endif %}" id="child_support_description">
<h3>If you are asking for an <h3>If you are asking for an
<span class="tooltip-link" <span class="tooltip-link"
@ -469,13 +469,9 @@
</p> </p>
</div> </div>
</div> </div>
</div> </div>
{% endblock content %} {% endblock content %}
{% block formBack %}{% prev_step step='children' sub_step='what_for' %}{% endblock %} {% block formBack %}{% prev_step step='children' sub_step='what_for' %}{% endblock %}
{% block formNext %}{% next_step step='children' sub_step='what_for' %}{% endblock %} {% block formNext %}{% next_step step='children' sub_step='what_for' %}{% endblock %}
@ -530,6 +526,4 @@
<li>where the children are going to live, and </li> <li>where the children are going to live, and </li>
<li>how much time the children will spend with each parent who is a guardian.</li> <li>how much time the children will spend with each parent who is a guardian.</li>
</ul> </ul>
{% endblock %} {% endblock %}

+ 15
- 3
edivorce/apps/core/templatetags/format_utils.py View File

@ -81,8 +81,16 @@ def checkbox(context, *args, **kwargs):
pass a False value as an argument. pass a False value as an argument.
""" """
args_pass = all(args) args_pass = all(args)
kwargs_pass = all([value in context['responses'].get(question, '')
for question, value in kwargs.items()])
kwargs_list = []
for question, value in kwargs.items():
if question in context['responses']:
dict_with_question = context['responses']
elif question in context['derived']:
dict_with_question = context['derived']
else:
raise KeyError(f'{question} not found in responses or derived')
kwargs_list.append(str(value) in str(dict_with_question[question]))
kwargs_pass = all(kwargs_list)
return mark_safe('<i class="fa fa%s-square-o" aria-hidden="true"></i>' % return mark_safe('<i class="fa fa%s-square-o" aria-hidden="true"></i>' %
('-check' if args_pass and kwargs_pass else '')) ('-check' if args_pass and kwargs_pass else ''))
@ -130,7 +138,11 @@ def money(amount, symbol=True):
except ValueError: except ValueError:
pass pass
return ''
try:
amount = float(amount)
return '{:.2f}'.format(amount)
except ValueError:
return amount
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)


+ 13
- 15
edivorce/apps/core/templatetags/step_order.py View File

@ -11,7 +11,7 @@ register = template.Library()
def _get_next_step(context, step, sub_step, direction): def _get_next_step(context, step, sub_step, direction):
want_which_orders = json.loads(context.get('want_which_orders', '[]')) want_which_orders = json.loads(context.get('want_which_orders', '[]'))
children_of_marriage = context.get('children_of_marriage', None)
children_of_marriage = context.get('derived', {}).get('has_children_of_marriage')
sub_step_name = _get_next_sub_step(step, sub_step, want_which_orders, sub_step_name = _get_next_sub_step(step, sub_step, want_which_orders,
children_of_marriage=children_of_marriage, children_of_marriage=children_of_marriage,
direction=direction) direction=direction)
@ -48,25 +48,23 @@ def _get_next_sub_step(step, sub_step, want_which_orders, children_of_marriage,
return None return None
def _adjust_for_orders(next_item, want_which_orders, children_of_marriage=None, direction=None):
def _adjust_for_orders(next_item, want_which_orders, children_of_marriage, direction):
print(children_of_marriage)
tests = [
lambda next_item: next_item == 6 and not children_of_marriage,
lambda next_item: next_item == 7 and 'Spousal support' not in want_which_orders,
lambda next_item: next_item == 8 and 'Division of property and debts' not in want_which_orders,
lambda next_item: next_item == 9 and 'Other orders' not in want_which_orders
]
addend = 1 addend = 1
if direction != 'next': if direction != 'next':
addend = -1 addend = -1
tests.reverse()
next_item += addend next_item += addend
if next_item == 6 and 'YES' != children_of_marriage:
next_item += addend
if next_item == 7 and 'Spousal support' not in want_which_orders:
next_item += addend
if next_item == 8 and 'Division of property and debts' not in want_which_orders:
next_item += addend
if next_item == 9 and 'Other orders' not in want_which_orders:
next_item += addend
for test in tests:
if test(next_item):
next_item += addend
return next_item return next_item


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

@ -3,7 +3,9 @@ import json
from django.test import TestCase from django.test import TestCase
from edivorce.apps.core.models import BceidUser, UserResponse from edivorce.apps.core.models import BceidUser, UserResponse
from edivorce.apps.core.templatetags.step_order import next_step, prev_step
from edivorce.apps.core.utils import conditional_logic as logic from edivorce.apps.core.utils import conditional_logic as logic
from edivorce.apps.core.utils.derived import get_derived_data
from edivorce.apps.core.utils.user_response import get_data_for_user from edivorce.apps.core.utils.user_response import get_data_for_user
from edivorce.apps.core.models import Document from edivorce.apps.core.models import Document
@ -116,3 +118,75 @@ class ViewLogic(TestCase):
self.assertEqual(Document.content_type_from_filename('redis_key_testfile_6_jpeg'), 'image/jpeg') self.assertEqual(Document.content_type_from_filename('redis_key_testfile_6_jpeg'), 'image/jpeg')
self.assertEqual(Document.content_type_from_filename('test_file7.HEIC'), 'application/unknown') self.assertEqual(Document.content_type_from_filename('test_file7.HEIC'), 'application/unknown')
self.assertEqual(Document.content_type_from_filename('redis_key_testfile_7_svgg'), 'application/unknown') self.assertEqual(Document.content_type_from_filename('redis_key_testfile_7_svgg'), 'application/unknown')
class TemplateTagLogic(TestCase):
fixtures = ['Question.json']
def setUp(self):
self.user = BceidUser.objects.create(user_guid='1234')
def create_response(self, question, value):
response, _ = UserResponse.objects.get_or_create(bceid_user=self.user, question_id=question)
response.value = value
response.save()
@property
def context(self):
responses_dict = get_data_for_user(self.user)
derived = get_derived_data(responses_dict)
responses_dict['derived'] = derived
return responses_dict
def test_next(self):
self.assertEqual(next_step(self.context, 'orders'), 'claimant')
self.assertEqual(next_step(self.context, 'claimant'), 'respondent')
self.assertEqual(next_step(self.context, 'respondent'), 'marriage')
self.assertEqual(next_step(self.context, 'marriage'), 'separation')
self.assertEqual(next_step(self.context, 'separation'), 'other_questions')
self.assertEqual(next_step(self.context, 'other_questions'), 'location')
self.create_response('want_which_orders', '["Other orders"]')
self.assertEqual(next_step(self.context, 'separation'), 'other_orders')
self.create_response('want_which_orders', '["Spousal support"]')
self.assertEqual(next_step(self.context, 'separation'), 'support')
self.create_response('want_which_orders', '["Division of property and debts"]')
self.assertEqual(next_step(self.context, 'separation'), 'property')
self.create_response('want_which_orders', '[]')
self.create_response('children_of_marriage', 'YES')
self.create_response('has_children_under_19', 'YES')
self.assertEqual(next_step(self.context, 'separation'), 'children/your_children/')
self.assertEqual(next_step(self.context, 'children', sub_step='your_children'), '/question/children/income_expenses/')
self.assertEqual(next_step(self.context, 'children', sub_step='income_expenses'), '/question/children/facts/')
self.assertEqual(next_step(self.context, 'children', sub_step='facts'), '/question/children/payor_medical/')
self.assertEqual(next_step(self.context, 'children', sub_step='payor_medical'), '/question/children/what_for/')
self.assertEqual(next_step(self.context, 'children', sub_step='what_for'), '/question/other_questions')
def test_previous(self):
self.assertEqual(prev_step(self.context, 'location'), 'other_questions')
self.assertEqual(prev_step(self.context, 'other_questions'), 'separation')
self.assertEqual(prev_step(self.context, 'separation'), 'marriage')
self.assertEqual(prev_step(self.context, 'marriage'), 'respondent')
self.assertEqual(prev_step(self.context, 'respondent'), 'claimant')
self.assertEqual(prev_step(self.context, 'claimant'), 'orders')
self.create_response('want_which_orders', '["Other orders"]')
self.assertEqual(prev_step(self.context, 'other_questions'), 'other_orders')
self.create_response('want_which_orders', '["Spousal support"]')
self.assertEqual(prev_step(self.context, 'other_questions'), 'support')
self.create_response('want_which_orders', '["Division of property and debts"]')
self.assertEqual(prev_step(self.context, 'other_questions'), 'property')
self.create_response('want_which_orders', '[]')
self.create_response('children_of_marriage', 'YES')
self.create_response('has_children_under_19', 'YES')
self.assertEqual(prev_step(self.context, 'other_questions'), 'children/what_for/')
self.assertEqual(prev_step(self.context, 'children', sub_step='what_for'), '/question/children/payor_medical/')
self.assertEqual(prev_step(self.context, 'children', sub_step='payor_medical'), '/question/children/facts/')
self.assertEqual(prev_step(self.context, 'children', sub_step='facts'), '/question/children/income_expenses/')
self.assertEqual(prev_step(self.context, 'children', sub_step='income_expenses'), '/question/children/your_children/')
self.assertEqual(prev_step(self.context, 'children', sub_step='your_children'), '/question/separation')

Loading…
Cancel
Save