class TestUnderThirtyYearsOld(TestCase): def setUp(self): risk_profile_builder = RiskProfileBuilder() self.risk_profile = risk_profile_builder \ .with_disability_product() \ .with_home_product() \ .with_life_product() \ .with_vehicle_product() \ .build() self.person_builder = PersonBuilder() self.rule = UnderThirtyYearsOld() def test_product_score_is_deduct_in_2_when_person_is_under_thirty_years_old(self): person = self.person_builder.with_age(29).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(-2, risk_analysis.get_products_in_risk_analysis()[DISABILITY_PRODUCT].get_score()) self.assertEqual(-2, risk_analysis.get_products_in_risk_analysis()[HOME_PRODUCT].get_score()) self.assertEqual(-2, risk_analysis.get_products_in_risk_analysis()[LIFE_PRODUCT].get_score()) self.assertEqual(-2, 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())
class TestIsOverSixtyYearsOld(TestCase): def setUp(self): risk_profile_builder = RiskProfileBuilder() self.risk_profile = risk_profile_builder \ .with_disability_product() \ .with_home_product() \ .with_life_product() \ .with_vehicle_product() \ .build() self.person_builder = PersonBuilder() self.rule = IsOverSixtyYearsOld() def test_product_score_is_ineligible_when_person_is_over_sixty_years_old( self): person = self.person_builder.with_age(61).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_INELIGIBLE, risk_analysis.get_products_in_risk_analysis() [LIFE_PRODUCT].get_status()) self.assertEqual( PRODUCT_SCORE_INELIGIBLE, risk_analysis.get_products_in_risk_analysis() [DISABILITY_PRODUCT].get_status()) 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())
class TestUnderThirtyYearsOld(TestCase): def setUp(self): risk_profile_builder = RiskProfileBuilder() self.risk_profile = risk_profile_builder \ .with_disability_product() \ .with_home_product() \ .with_life_product() \ .with_vehicle_product() \ .build() self.person_builder = PersonBuilder() self.rule = BetweenThirtyAndFortyYearsOld() def test_is_truly_when_person_is_between_thirty_and_forty_years_old(self): person = self.person_builder.with_age(40).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( -1, 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( -1, 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())