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)

        # Test for marriage-like relationship
        create_response(user, 'married_marriage_like',
                        'Living together in a marriage like relationship')
        questions.append('married_marriage_like')

        # 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)

        # Two required question
        create_response(user, 'address_to_send_official_document_city_you',
                        '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)

        # Three required question
        create_response(user, 'address_to_send_official_document_prov_you',
                        '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)

        # 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)

        # 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)

        # 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)

        # 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)

        # 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)

        # 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)

        # All required questions for spouse and you
        create_response(
            user, '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)

        # All required questions for spouse and you with empty email(optional so still true)
        create_response(user, 'address_to_send_official_document_email_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], True)

        # Test for Legally Married state
        UserResponse.objects.filter(
            question_id='married_marriage_like').update(
                value="Legally married")

        # Missing some required questions for legally married state
        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)

        # 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)

        # Missing 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)

        # 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)

        # 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)

        # 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)

        # 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)
    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)

        # 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')

        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)

        # 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)

        # 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)

        # 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)

        # 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)

        # 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)

        # 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)

        # 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)

        # 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)
    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)

        # Test for marriage-like relationship
        create_response(user, 'married_marriage_like',
                        'Living together in a marriage like relationship')
        questions.append('married_marriage_like')

        # One required question
        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)

        # One required question and one not shown question(shouldn't be affecting)
        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)

        # Two required question and one not shown question(shouldn't be affecting)
        create_response(user, 'marital_status_before_you', 'Never married')

        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)

        # All required question and one not shown question(shouldn't be affecting)
        create_response(user, 'marital_status_before_spouse', 'Widowed')

        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)

        # Test for Legally Married state
        UserResponse.objects.filter(
            question_id='married_marriage_like').update(
                value="Legally married")

        # Missing some required questions
        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_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')

        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)

        # 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)

        # 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)

        # 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)
    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)

        # All required question with no hidden shown
        create_response(user, '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)

        # 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)

        # 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)

        # 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)

        # 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)

        # 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)
Example #5
0
 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])