def test_should_assert_risk_profile(self):
        age = 35
        income = 0
        dependents = 2
        house = 'owned'
        marital_status = 'married'
        risk_questions = [0, 1, 0]
        vehicle_year = dt.now().year - 2

        auto_profile_expected = UserProfileStatus.REGULAR
        disability_profile_expected = UserProfileStatus.INELIGIBLE
        home_profile_expected = UserProfileStatus.ECONOMIC
        life_profile_expected = UserProfileStatus.REGULAR

        errors = []

        customer_insurances = Customer(age, income, dependents, house,
                                       marital_status, risk_questions,
                                       vehicle_year).get_risk_profile()

        for insurance in customer_insurances:
            if insurance.name == 'Auto' and insurance.profile != auto_profile_expected:
                errors.append('Auto')
            elif insurance.name == 'Disability' and insurance.profile != disability_profile_expected:
                errors.append('Disability')
            elif insurance.name == 'Home' and insurance.profile != home_profile_expected:
                errors.append('Home')
            elif insurance.name == 'Life' and insurance.profile != life_profile_expected:
                errors.append('Life')

        assert len(errors) == 0
Example #2
0
def customer_input_mapper(customer_request: CustomerRequest) -> Customer:
    house_status = customer_request.house.ownership_status if customer_request.house else OwnershipStatus.HAS_NOT
    year_vehicle = customer_request.vehicle.year if customer_request.vehicle else 0
    return Customer(customer_request.age, customer_request.income,
                    customer_request.dependents, house_status,
                    customer_request.marital_status,
                    customer_request.risk_questions, year_vehicle)