def test_product_score_is_default_when_person_is_under_sixty_years_old( self): person = self.person_builder.with_age(60).build() risk_analysis = RiskAnalysis(person=person, risk_profile=self.risk_profile, rules_list=None) risk_analysis = self.rule.execute(risk_analysis=risk_analysis) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [HOME_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [VEHICLE_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [LIFE_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_status())
def test_product_score_remains_in_0_when_house_is_not_mortgaged(self): house = House(ownership_status=OWNERSHIP_STATUS_OWNED) self.person_builder.person.assets = [] person = self.person_builder.with_asset(asset=house).build() risk_analysis = RiskAnalysis(person=person, risk_profile=self.risk_profile, rules_list=None) risk_analysis = self.rule.execute(risk_analysis=risk_analysis) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [HOME_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [LIFE_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [VEHICLE_PRODUCT].get_score())
def test_product_score_is_not_deduct_in_1_when_person_has_income_bellow_two_hundred( self): person = self.person_builder.with_income(200.00).build() risk_analysis = RiskAnalysis(person=person, risk_profile=self.risk_profile, rules_list=None) risk_analysis = self.rule.execute(risk_analysis=risk_analysis) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [HOME_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [LIFE_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [VEHICLE_PRODUCT].get_score())
def test_home_product_status_is_default_when_person_has_house(self): house = House(ownership_status=OWNERSHIP_STATUS_OWNED) person = self.person_builder.with_asset(asset=house).build() risk_analysis = RiskAnalysis(person=person, risk_profile=self.risk_profile, rules_list=None) risk_analysis = self.rule.execute(risk_analysis=risk_analysis) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [HOME_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [VEHICLE_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [LIFE_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_status())
def test_product_score_is_not_add_in_1_and_not_deduct_in_1_when_person_is_single( self): person = self.person_builder.with_marital_status( MARITAL_STATUS_SINGLE).build() risk_analysis = RiskAnalysis(person=person, risk_profile=self.risk_profile, rules_list=None) risk_analysis = self.rule.execute(risk_analysis=risk_analysis) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [HOME_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [LIFE_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [VEHICLE_PRODUCT].get_score())
def test_vehicle_product_status_is_default_when_person_has_vehicle(self): vehicle = Vehicle(year_manufactured=2019) person = self.person_builder.with_asset(asset=vehicle).build() risk_analysis = RiskAnalysis(person=person, risk_profile=self.risk_profile, rules_list=None) risk_analysis = self.rule.execute(risk_analysis=risk_analysis) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [HOME_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [VEHICLE_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [LIFE_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_status())
def test_vehicle_product_status_is_ineligible_when_person_has_no_vehicle( self): person = self.person_builder.build() risk_analysis = RiskAnalysis(person=person, risk_profile=self.risk_profile, rules_list=None) risk_analysis = self.rule.execute(risk_analysis=risk_analysis) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [HOME_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_INELIGIBLE, risk_analysis.get_products_in_risk_analysis() [VEHICLE_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [LIFE_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_ECONOMIC, risk_analysis.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_status())
def test_product_score_is_not_add_in_1_when_vehicle_was_produced_last_5_years( self): vehicle = Vehicle(year_manufactured=2013) self.person_builder.person.assets = [] person = self.person_builder.with_asset(asset=vehicle).build() risk_analysis = RiskAnalysis(person=person, risk_profile=self.risk_profile, rules_list=None) risk_analysis = self.rule.execute(risk_analysis=risk_analysis) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [HOME_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [LIFE_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis.get_products_in_risk_analysis() [VEHICLE_PRODUCT].get_score())
def test_product_score_is_not_deduct_in_2_when_person_is_over_thirty_years_old(self): person = self.person_builder.with_age(30).build() risk_analysis = RiskAnalysis(person=person, risk_profile=self.risk_profile, rules_list=None) risk_analysis = self.rule.execute(risk_analysis=risk_analysis) self.assertEqual(0, risk_analysis.get_products_in_risk_analysis()[DISABILITY_PRODUCT].get_score()) self.assertEqual(0, risk_analysis.get_products_in_risk_analysis()[HOME_PRODUCT].get_score()) self.assertEqual(0, risk_analysis.get_products_in_risk_analysis()[LIFE_PRODUCT].get_score()) self.assertEqual(0, risk_analysis.get_products_in_risk_analysis()[VEHICLE_PRODUCT].get_score())
def test_product_score_is_add_in_1_when_person_has_dependents(self): person = self.person_builder.with_dependents(1).build() risk_analysis = RiskAnalysis(person=person, risk_profile=self.risk_profile, rules_list=None) risk_analysis = self.rule.execute(risk_analysis=risk_analysis) self.assertEqual(+1, risk_analysis.get_products_in_risk_analysis()[DISABILITY_PRODUCT].get_score()) self.assertEqual(0, risk_analysis.get_products_in_risk_analysis()[HOME_PRODUCT].get_score()) self.assertEqual(+1, risk_analysis.get_products_in_risk_analysis()[LIFE_PRODUCT].get_score()) self.assertEqual(0, risk_analysis.get_products_in_risk_analysis()[VEHICLE_PRODUCT].get_score())
def test_is_falsely_when_person_is_not_between_thirty_and_forty_years_old( self): she = self.person_builder.with_age(29).build() risk_analysis_she = RiskAnalysis(person=she, risk_profile=self.risk_profile, rules_list=None) he = self.person_builder.with_age(41).build() risk_analysis_he = RiskAnalysis(person=he, risk_profile=self.risk_profile, rules_list=None) risk_analysis_she = self.rule.execute(risk_analysis=risk_analysis_she) risk_analysis_he = self.rule.execute(risk_analysis=risk_analysis_he) self.assertEqual( 0, risk_analysis_she.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis_she.get_products_in_risk_analysis() [HOME_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis_she.get_products_in_risk_analysis() [LIFE_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis_she.get_products_in_risk_analysis() [VEHICLE_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis_he.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis_he.get_products_in_risk_analysis() [HOME_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis_he.get_products_in_risk_analysis() [LIFE_PRODUCT].get_score()) self.assertEqual( 0, risk_analysis_he.get_products_in_risk_analysis() [VEHICLE_PRODUCT].get_score())