@ -3,592 +3,346 @@ from edivorce.apps.core.models import UserResponse, Question, BceidUser
from edivorce.apps.core.utils.step_completeness import is_complete
from edivorce.apps.core.utils.question_step_mapping import question_step_mapping
# Create your tests here.
from edivorce.apps.core.utils.user_response import get_data_for_user , get_step_responses
class UserResponseTestCase ( TestCase ) :
fixtures = [ ' Question.json ' ]
def setUp ( self ) :
BceidUser . objects . create ( user_guid = ' 1234 ' )
self . user = BceidUser . objects . create ( user_guid = ' 1234 ' )
def check_completeness ( self , step ) :
responses_dict = get_data_for_user ( self . user )
responses_dict_by_step = get_step_responses ( responses_dict )
return is_complete ( responses_dict_by_step [ step ] ) [ 0 ]
def create_response ( self , question , value ) :
UserResponse . objects . create ( bceid_user = self . user , question = Question . objects . get ( key = question ) , value = value )
def test_which_order ( self ) :
step = ' which_orders '
questions = question_step_mapping [ step ]
user = BceidUser . objects . get ( user_guid = ' 1234 ' )
# No response should be False
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required question
create_response ( user , ' want_which_orders ' , ' [ " nothing " ] ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' want_which_orders ' , ' [ " nothing " ] ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# Put empty response
UserResponse . objects . filter ( question_id = ' want_which_orders ' ) . update ( value = " [] " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
def test_your_info ( self ) :
step = ' your_information '
questions = question_step_mapping [ step ]
user = BceidUser . objects . get ( user_guid = ' 1234 ' )
# No response should be False
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# Testing required questions
# Missing few required questions
create_response ( user , ' name_you ' , ' John Doe ' )
create_response ( user , ' last_name_before_married_you ' , ' Jackson ' )
create_response ( user , ' birthday_you ' , ' 11/11/1111 ' )
create_response ( user , ' occupation_you ' , ' Plumber ' )
self . create_response ( ' name_you ' , ' John Doe ' )
self . create_response ( ' last_name_before_married_you ' , ' Jackson ' )
self . create_response ( ' birthday_you ' , ' 11/11/1111 ' )
self . create_response ( ' occupation_you ' , ' Plumber ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# Few required questions with one checking question with hidden question not shown
create_response ( user , ' lived_in_bc_you ' , ' 11/11/1111 ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' lived_in_bc_you ' , ' 11/11/1111 ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions with one checking question with hidden question not shown
create_response ( user , ' last_name_born_you ' , ' Jackson ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' last_name_born_you ' , ' Jackson ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions with one checking question with hidden question missing
UserResponse . objects . filter ( question_id = ' lived_in_bc_you ' ) . update ( value = " Moved to B.C. on " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions with one checking question with hidden question
create_response ( user , ' moved_to_bc_date_you ' , ' 12/12/1212 ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' moved_to_bc_date_you ' , ' 12/12/1212 ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions with two checking question with one hidden and one shown
create_response ( user , ' any_other_name_you ' , ' NO ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' any_other_name_you ' , ' NO ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# All required questions with two checking question with one hidden question missing
UserResponse . objects . filter ( question_id = ' any_other_name_you ' ) . update ( value = " YES " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions with all checking question with all hidden questions
create_response ( user , ' other_name_you ' , ' [[ " also known as " , " Smith " ]] ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' other_name_you ' , ' [[ " also known as " , " Smith " ]] ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# Put empty response
UserResponse . objects . filter ( question_id = ' other_name_you ' ) . update ( value = ' [[ " " , " " ]] ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
def test_your_spouse ( self ) :
step = ' your_spouse '
questions = question_step_mapping [ step ]
user = BceidUser . objects . get ( user_guid = ' 1234 ' )
# No response should be False
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# Testing required questions
# Missing few required questions
create_response ( user , ' name_spouse ' , ' John Doe ' )
create_response ( user , ' last_name_before_married_spouse ' , ' Jackson ' )
create_response ( user , ' birthday_spouse ' , ' 11/11/1111 ' )
create_response ( user , ' occupation_spouse ' , ' Electrician ' )
self . create_response ( ' name_spouse ' , ' John Doe ' )
self . create_response ( ' last_name_before_married_spouse ' , ' Jackson ' )
self . create_response ( ' birthday_spouse ' , ' 11/11/1111 ' )
self . create_response ( ' occupation_spouse ' , ' Electrician ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# Few required questions with one checking question with hidden question not shown
create_response ( user , ' any_other_name_spouse ' , ' NO ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' any_other_name_spouse ' , ' NO ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions with one checking question with hidden question not shown
create_response ( user , ' last_name_born_spouse ' , ' Jackson ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
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 " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions with one checking question with hidden question
create_response ( user , ' lived_in_bc_spouse ' , ' Since birth ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' lived_in_bc_spouse ' , ' Since birth ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions with two checking question with one hidden and one shown
create_response ( user , ' other_name_spouse ' , ' [[ " also known as " , " Smith " ]] ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' other_name_spouse ' , ' [[ " also known as " , " Smith " ]] ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# All required questions with two checking question with one hidden question missing
UserResponse . objects . filter ( question_id = ' lived_in_bc_spouse ' ) . update ( value = " Moved to B.C. on " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions with all checking question with all hidden questions
create_response ( user , ' moved_to_bc_date_spouse ' , ' 12/12/1212 ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' moved_to_bc_date_spouse ' , ' 12/12/1212 ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# Put empty response
UserResponse . objects . filter ( question_id = ' name_spouse ' ) . update ( value = " " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# Put empty response
UserResponse . objects . filter ( question_id = ' other_name_spouse ' ) . update ( value = ' [[ " " , " " ]] ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
def test_your_marriage ( self ) :
step = ' your_marriage '
questions = question_step_mapping [ step ]
user = BceidUser . objects . get ( user_guid = ' 1234 ' )
# No response should be False
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
# Some required questions
create_response ( user , ' when_were_you_live_married_like ' , ' 12/12/2007 ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# Some required questions
create_response ( user , ' when_were_you_married ' , ' 12/12/2008 ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' when_were_you_live_married_like ' , ' 12/12/2007 ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# Some required questions
create_response ( user , ' marital_status_before_you ' , ' Never married ' )
self . create_response ( ' when_were_you_married ' , ' 12/12/2008 ' )
self . assertEqual ( self . check_completeness ( step ) , False )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
# Some required questions
create_response ( user , ' marital_status_before_spouse ' , ' Widowed ' )
self . create_response ( ' marital_status_before_you ' , ' Never married ' )
self . assertEqual ( self . check_completeness ( step ) , False )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' marital_status_before_spouse ' , ' Widowed ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# Some required questions
create_response ( user , ' where_were_you_married_city ' , ' Vancouver ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
# Some required questions
create_response ( user , ' where_were_you_married_prov ' , ' BC ' )
self . create_response ( ' where_were_you_married_city ' , ' Vancouver ' )
self . assertEqual ( self . check_completeness ( step ) , False )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' where_were_you_married_prov ' , ' BC ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions
create_response ( user , ' where_were_you_married_country ' , ' Canada ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' where_were_you_married_country ' , ' Canada ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# All required questions but missing conditional question
UserResponse . objects . filter ( question_id = ' where_were_you_married_country ' ) . update ( value = " Other " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions
create_response ( user , ' where_were_you_married_other_country ' , ' Peru ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' where_were_you_married_other_country ' , ' Peru ' )
self . assertEqual ( self . check_completeness ( step ) , True )
def test_your_separation ( self ) :
step = ' your_separation '
questions = question_step_mapping [ step ]
user = BceidUser . objects . get ( user_guid = ' 1234 ' )
# No response should be False
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required question
create_response ( user , ' no_reconciliation_possible ' , ' I agree ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' no_reconciliation_possible ' , ' I agree ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# Put empty response
UserResponse . objects . filter ( question_id = ' no_reconciliation_possible ' ) . update ( value = " " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
def test_spousal_support ( self ) :
step = ' spousal_support '
questions = question_step_mapping [ step ]
user = BceidUser . objects . get ( user_guid = ' 1234 ' )
# No response should be False
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# One required question
create_response ( user , ' spouse_support_details ' , ' I will support you ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' spouse_support_details ' , ' I will support you ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# Two required questions
create_response ( user , ' spouse_support_act ' , ' Family Law ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' spouse_support_act ' , ' Family Law ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# Remove first added required response to test the second required question
UserResponse . objects . get ( question_id = ' spouse_support_details ' ) . delete ( )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# Put empty response
UserResponse . objects . filter ( question_id = ' spouse_support_details ' ) . update ( value = " " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
def test_property_and_debt ( self ) :
step = ' property_and_debt '
questions = question_step_mapping [ step ]
user = BceidUser . objects . get ( user_guid = ' 1234 ' )
# No response should be False
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required question with no hidden shown
create_response ( user , ' deal_with_property_debt ' , ' Equal division ' )
self . create_response ( ' deal_with_property_debt ' , ' Equal division ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . assertEqual ( self . check_completeness ( step ) , True )
# All required question with hidden shown but no response
UserResponse . objects . filter ( question_id = ' deal_with_property_debt ' ) . update ( value = " Unequal division " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# Only one required question with hidden shown and answered
create_response ( user , ' how_to_divide_property_debt ' , ' Do not divide them ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' how_to_divide_property_debt ' , ' Do not divide them ' )
# Only two required question with hidden shown and answered
# NOTE: want_other_property_claims not in use anymore
# create_response(user, 'want_other_property_claims', '["Ask for other property claims"]')
#
# lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value', 'question__conditional_target', 'question__reveal_response', 'question__required')
# self.assertEqual(is_complete(step, lst)[0], False)
self . assertEqual ( self . check_completeness ( step ) , True )
# All required question with hidden shown and answered
create_response ( user , ' other_property_claims ' , ' Want these property claims ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
# All required question with optional fields
self . create_response ( ' other_property_claims ' , ' Want these property claims ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# Put empty response
# UserResponse.objects.filter(question_id='want_other_property_claims').update(value="")
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
UserResponse . objects . filter ( question_id = ' want_other_property_claims ' ) . update ( value = " " )
self . assertEqual ( self . check_completeness ( step ) , True )
def test_other_orders ( self ) :
step = ' other_orders '
questions = question_step_mapping [ step ]
user = BceidUser . objects . get ( user_guid = ' 1234 ' )
# No response should be False
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required question
self . create_response ( ' name_change_you ' , ' NO ' )
self . assertEqual ( self . check_completeness ( step ) , False )
create_response ( user , ' name_change_you ' , ' NO ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
create_response ( user , ' name_change_spouse ' , ' NO ' )
create_response ( user , ' other_orders_detail ' , ' I want more orders ' )
self . create_response ( ' name_change_spouse ' , ' NO ' )
self . create_response ( ' other_orders_detail ' , ' I want more orders ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . assertEqual ( self . check_completeness ( step ) , True )
# make incomplete
UserResponse . objects . filter ( question_id = ' name_change_spouse ' ) . update ( value = " YES " )
self . assertEqual ( self . check_completeness ( step ) , False )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
create_response ( user , ' name_change_spouse_fullname ' , ' new name ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' name_change_spouse_fullname ' , ' new name ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# Put empty response
UserResponse . objects . filter ( question_id = ' other_orders_detail ' ) . update ( value = " " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . assertEqual ( self . check_completeness ( step ) , True )
def test_other_questions ( self ) :
step = ' other_questions '
questions = question_step_mapping [ step ]
user = BceidUser . objects . get ( user_guid = ' 1234 ' )
# No response should be False
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
# One required question
create_response ( user , ' address_to_send_official_document_street_you ' , ' 123 Cambie st ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# Two required question
create_response ( user , ' address_to_send_official_document_city_you ' , ' Vancouver ' )
# Some required question
self . create_response ( ' address_to_send_official_document_street_you ' , ' 123 Cambie st ' )
self . assertEqual ( self . check_completeness ( step ) , False )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' address_to_send_official_document_city_you ' , ' Vancouver ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# Three required question
create_response ( user , ' address_to_send_official_document_prov_you ' , ' BC ' )
self . create_response ( ' address_to_send_official_document_prov_you ' , ' BC ' )
self . assertEqual ( self . check_completeness ( step ) , False )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
# Four required question
create_response ( user , ' address_to_send_official_document_country_you ' , ' Canada ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' address_to_send_official_document_country_you ' , ' Canada ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions for you
create_response ( user , ' address_to_send_official_document_postal_code_you ' , ' Canada ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' address_to_send_official_document_postal_code_you ' , ' Canada ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# One required question for spouse
create_response ( user , ' address_to_send_official_document_street_spouse ' , ' 123 Cambie st ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' address_to_send_official_document_street_spouse ' , ' 123 Cambie st ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# Two required question for spouse
create_response ( user , ' address_to_send_official_document_city_spouse ' , ' Vancouver ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' address_to_send_official_document_city_spouse ' , ' Vancouver ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# Three required question for spouse
create_response ( user , ' address_to_send_official_document_prov_spouse ' , ' BC ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' address_to_send_official_document_prov_spouse ' , ' BC ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# Four required question for spouse
create_response ( user , ' address_to_send_official_document_country_spouse ' , ' Canada ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . create_response ( ' address_to_send_official_document_country_spouse ' , ' Canada ' )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions
create_response ( user , ' divorce_take_effect_on ' , ' the 31st day after the date of this order ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' divorce_take_effect_on ' , ' the 31st day after the date of this order ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# Missing conditional required question
UserResponse . objects . filter ( question_id = ' divorce_take_effect_on ' ) . update ( value = " specific date " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions
create_response ( user , ' divorce_take_effect_on_specific_date ' , ' 12/12/2018 ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' divorce_take_effect_on_specific_date ' , ' 12/12/2018 ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# All required questions for spouse and you
create_response ( user , ' address_to_send_official_document_postal_code_spouse ' , ' Canada ' )
self . create_response ( ' address_to_send_official_document_postal_code_spouse ' , ' Canada ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . assertEqual ( self . check_completeness ( step ) , True )
# All required questions for spouse and you with empty email(optional so still true)
create_response ( user , ' address_to_send_official_document_email_you ' , ' a@example.com ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' address_to_send_official_document_email_you ' , ' a@example.com ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# Testing other country missing
UserResponse . objects . filter ( question_id = ' address_to_send_official_document_country_spouse ' ) . update ( value = " Other " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required questions
create_response ( user , ' address_to_send_official_document_other_country_spouse ' , ' Mexico ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' address_to_send_official_document_other_country_spouse ' , ' Mexico ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# Set Specific date on to empty
UserResponse . objects . filter ( question_id = ' divorce_take_effect_on_specific_date ' ) . update ( value = " " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' ,
' question__conditional_target ' ,
' question__reveal_response ' ,
' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
def test_filing_locations ( self ) :
step = ' filing_locations '
questions = question_step_mapping [ step ]
user = BceidUser . objects . get ( user_guid = ' 1234 ' )
# No response should be False
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
self . assertEqual ( self . check_completeness ( step ) , False )
# All required question
create_response ( user , ' court_registry_for_filing ' , ' Vancouver ' )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , True )
self . create_response ( ' court_registry_for_filing ' , ' Vancouver ' )
self . assertEqual ( self . check_completeness ( step ) , True )
# Put empty response
UserResponse . objects . filter ( question_id = ' court_registry_for_filing ' ) . update ( value = " " )
lst = UserResponse . objects . filter ( question_id__in = questions ) . values ( ' question_id ' , ' value ' , ' question__conditional_target ' , ' question__reveal_response ' , ' question__required ' )
self . assertEqual ( is_complete ( step , lst ) [ 0 ] , False )
# Helper functions
def create_response ( user , question , value ) :
UserResponse . objects . create ( bceid_user = user , question = Question . objects . get ( key = question ) , value = value )
self . assertEqual ( self . check_completeness ( step ) , False )