class TestHasIncome(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 = HasIncome() def test_product_status_is_default_when_person_has_income(self): person = self.person_builder.with_income(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( 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_status_is_ineligible_when_person_has_no_income(self): person = self.person_builder.with_income(0).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_INELIGIBLE, risk_analysis.get_products_in_risk_analysis() [DISABILITY_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() [HOME_PRODUCT].get_status())
class TestHasIncomeAboveTwoHundred(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 = HasIncomeAboveTwoHundred() def test_product_score_is_deduct_in_1_when_person_has_income_above_two_hundred( self): person = self.person_builder.with_income(201.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( -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() [DISABILITY_PRODUCT].get_score()) self.assertEqual( -1, 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())