Esempio n. 1
0
 def test_returns_all_possible_insurance(self, user_data):
     user_data["income"] = 0
     insurance = user_insurance.get_user_insurance(UserInfo(**user_data))
     expected_value = {
         "auto": [{
             "key": 1,
             "value": "regular"
         }],
         "disability":
         "ineligible",
         "home": [
             {
                 "key": 1,
                 "value": "economic"
             },
             {
                 "key": 2,
                 "value": "regular"
             },
         ],
         "life":
         "regular",
         "umbrella":
         "regular",
     }
     assert insurance.dict() == expected_value
Esempio n. 2
0
 def test_when_house_key_is_missing_it_raises_an_error(self, user_data):
     user_data["houses"] = [
         {
             "ownership_status": "mortgaged"
         },
         {
             "key": 2,
             "ownership_status": "mortgaged"
         },
     ]
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 3
0
 def test_when_house_is_valid_it_creates_an_instance(self, user_data):
     user_data["houses"] = [
         {
             "key": 1,
             "ownership_status": "owned"
         },
         {
             "key": 2,
             "ownership_status": "mortgaged"
         },
     ]
     UserInfo(**user_data)
Esempio n. 4
0
 def _get_insurance(self, user_data):
     return user_insurance.DisabilityInsurance(UserInfo(**user_data))
Esempio n. 5
0
 def test_when_house_is_missing_it_raises_an_error(self, user_data):
     user_data.pop("houses")
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 6
0
 def test_when_n_dependents_is_negative_it_raises_an_error(self, user_data):
     user_data["dependents"] = -1
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 7
0
 def test_when_n_dependents_is_missing_it_raises_an_error(self, user_data):
     user_data.pop("dependents")
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 8
0
 def test_when_marital_status_is_negative_it_raises_an_error(
         self, user_data):
     user_data["marital_status"] = "dead"
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 9
0
 def test_when_user_info_is_valid_it_creates_an_intance(self, user_data):
     UserInfo(**user_data)
Esempio n. 10
0
 def test_when_vehicle_year_is_invalid_it_raises_an_error(self, user_data):
     user_data["vehicles"] = [{"key": 1, "year": -1}]
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 11
0
 def test_when_vehicle_key_is_missing_it_raises_an_error(self, user_data):
     user_data["vehicles"] = [{"year": 2018}]
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 12
0
 def test_when_risk_questions_have_an_invalid_value_it_raises_an_error(
         self, user_data):
     user_data["risk_questions"] = [True, False, 100]
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 13
0
 def test_when_risk_questions_is_missing_a_value_it_raises_an_error(
         self, user_data):
     user_data["risk_questions"] = [True, False]
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 14
0
 def test_when_risk_questions_is_missing_it_raises_an_error(
         self, user_data):  # noqa: E501
     user_data.pop("risk_questions")
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 15
0
 def test_when_age_is_negative_it_raises_an_error(self, user_data):
     user_data["age"] = -1
     with pytest.raises(ValidationError):
         UserInfo(**user_data)
Esempio n. 16
0
 def _get_insurance(self, user_data):
     return user_insurance.AutoInsurance(UserInfo(**user_data))
Esempio n. 17
0
 def test_when_marital_status_is_missing_it_raises_an_error(
         self, user_data):  # noqa: E501
     user_data.pop("marital_status")
     with pytest.raises(ValidationError):
         UserInfo(**user_data)