def test_calculate_dependents(self): profile = Profile(**self.payload) insurance = InsuranceCalculate(profile) insurance.calculate_dependents() self.assertEqual(insurance.disability, 1) self.assertEqual(insurance.life, 1)
def test_calculate_house_status(self): profile = Profile(**self.payload) insurance = InsuranceCalculate(profile) insurance.calculate_house() self.assertEqual(insurance.home, 0) self.assertEqual(insurance.disability, 0)
def test_calculate_marital_status(self): profile = Profile(**self.payload) insurance = InsuranceCalculate(profile) insurance.calculate_marital_status() self.assertEqual(insurance.auto, 0) self.assertEqual(insurance.life, 1) self.assertEqual(insurance.disability, 0)
def test_calculate_income(self): profile = Profile(**self.payload) insurance = InsuranceCalculate(profile) insurance.calculate_income() self.assertEqual(insurance.auto, 0) self.assertEqual(insurance.disability, 0) self.assertEqual(insurance.home, 0) self.assertEqual(insurance.life, 0)
def create(self, request): serializer = RiskProfileSerializers(data=request.data) if serializer.is_valid(): profile = Profile(**serializer.data) insurance = InsuranceCalculate(profile) return Response(insurance.calculate_risk_profile(), status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def test_calculate_risk_profile(self): profile = Profile(**self.payload) insurance = InsuranceCalculate(profile) insurance.calculate_disability() insurance.calculate_age() insurance.calculate_income() insurance.calculate_house() insurance.calculate_dependents() insurance.calculate_marital_status() insurance.calculate_vehicle_age() self.assertEqual(insurance.translated_field('auto'), 'regular') self.assertEqual(insurance.translated_field('disability'), 'ineligible') self.assertEqual(insurance.translated_field('home'), 'economic') self.assertEqual(insurance.translated_field('life'), 'regular')
def test_calculate_vehicle_age(self): profile = Profile(**self.payload) insurance = InsuranceCalculate(profile) insurance.calculate_vehicle_age() self.assertEqual(insurance.auto, 1)
def test_calculate_disability(self): profile = Profile(**self.payload) insurance = InsuranceCalculate(profile) insurance.calculate_disability() self.assertEqual(insurance.disability, 'ineligible')