def post(self): title = self.get_argument("title", None) name = self.get_argument("name", None) age = self.get_argument("age", None) address = self.get_argument("address", None) phone = self.get_argument("phone", None) email = self.get_argument("email", None) type = self.get_argument("type", None) enable = self.get_argument("enable", None) customer = Customer(None) customer.title = title customer.name = name customer.age = age customer.address = address customer.phone = phone.split(",") customer.email = email customer_type = CustomerType(None) customer_type.key = type customer.type = customer_type customer.enable = enable customer_service.add(customer) self.set_header("Content-Type", "text/plain") self.write("成功")
def test_should_assert_risk_profile(self): age = 35 income = 0 dependents = 2 house = 'owned' marital_status = 'married' risk_questions = [0, 1, 0] vehicle_year = dt.now().year - 2 auto_profile_expected = UserProfileStatus.REGULAR disability_profile_expected = UserProfileStatus.INELIGIBLE home_profile_expected = UserProfileStatus.ECONOMIC life_profile_expected = UserProfileStatus.REGULAR errors = [] customer_insurances = Customer(age, income, dependents, house, marital_status, risk_questions, vehicle_year).get_risk_profile() for insurance in customer_insurances: if insurance.name == 'Auto' and insurance.profile != auto_profile_expected: errors.append('Auto') elif insurance.name == 'Disability' and insurance.profile != disability_profile_expected: errors.append('Disability') elif insurance.name == 'Home' and insurance.profile != home_profile_expected: errors.append('Home') elif insurance.name == 'Life' and insurance.profile != life_profile_expected: errors.append('Life') assert len(errors) == 0
def customer_input_mapper(customer_request: CustomerRequest) -> Customer: house_status = customer_request.house.ownership_status if customer_request.house else OwnershipStatus.HAS_NOT year_vehicle = customer_request.vehicle.year if customer_request.vehicle else 0 return Customer(customer_request.age, customer_request.income, customer_request.dependents, house_status, customer_request.marital_status, customer_request.risk_questions, year_vehicle)
def test_add(): customer = Customer(None) customer.title = "王先生" customer.phone = ["15652318567", "13126714247", "18599392408"] customer.name = "王光明" customer.age = 33 customer.email = "*****@*****.**" customer.address = "中国北京" customer.type = CustomerType(None) customer.type.key = "1" customer.enable = True customer_id = customer_service.add(customer) print(customer_id)
def post(self): title = self.get_argument("title", None) name = self.get_argument("name", None) age = self.get_argument("age", None) phone = self.get_argument("phone", None) email = self.get_argument("email", None) address = self.get_argument("address", None) customer = Customer() customer.title = title customer.name = name customer.age = age customer.phone = phone customer.email = email customer.address = address customer.id = customer_service.max_id() + 1 customer_service.add(customer) self.redirect("/customers")