Example #1
0
def create_test_policy_holder_insuree(policy_holder=None,
                                      insuree=None,
                                      contribution_plan_bundle=None,
                                      last_policy=None,
                                      custom_props={}):
    if not policy_holder:
        policy_holder = create_test_policy_holder()
    if not insuree:
        insuree = create_test_insuree()
    if not contribution_plan_bundle:
        contribution_plan_bundle = create_test_contribution_plan_bundle()
    if not last_policy:
        last_policy = create_test_policy(product=create_test_product(
            "TestCode", custom_props={
                "insurance_period": 12,
            }),
                                         insuree=insuree)

    user = __get_or_create_simple_policy_holder_user()

    object_data = {
        'policy_holder': policy_holder,
        'insuree': insuree,
        'contribution_plan_bundle': contribution_plan_bundle,
        'last_policy': last_policy,
        'json_ext': json.dumps("{}"),
        **custom_props
    }

    policy_holder_insuree = PolicyHolderInsuree(**object_data)
    policy_holder_insuree.save(username=user.username)

    return policy_holder_insuree
    def setUpClass(cls):
        if not User.objects.filter(username='******').exists():
            User.objects.create_superuser(username='******',
                                          password='******')
        cls.user = User.objects.filter(username='******').first()
        cls.contract_service = ContractService(cls.user)
        cls.income = 500
        cls.rate = 5
        cls.number_of_insuree = 5
        cls.policy_holder = create_test_policy_holder()
        # create contribution plans etc
        cls.contribution_plan_bundle = create_test_contribution_plan_bundle()
        cls.contribution_plan = create_test_contribution_plan(custom_props={
            "json_ext":
            '{"calculation_rule":{"rate": "' + str(cls.rate) + '"}}'
        })
        cls.contribution_plan_bundle_details = create_test_contribution_plan_bundle_details(
            contribution_plan=cls.contribution_plan,
            contribution_plan_bundle=cls.contribution_plan_bundle)

        # create policy holder insuree for that test policy holder
        for i in range(0, cls.number_of_insuree):
            create_test_policy_holder_insuree(
                policy_holder=cls.policy_holder,
                contribution_plan_bundle=cls.contribution_plan_bundle,
                custom_props={
                    "last_policy":
                    None,
                    "json_ext":
                    '{"calculation_rule":{"income": "' + str(cls.income) +
                    '"}}'
                })
Example #3
0
def create_test_contract_details(contract=None,
                                 insuree=None,
                                 contribution_plan_bundle=None,
                                 custom_props={}):
    if not contract:
        contract = create_test_contract()

    if not insuree:
        insuree = create_test_insuree()

    if not contribution_plan_bundle:
        contribution_plan_bundle = create_test_contribution_plan_bundle()

    user = __get_or_create_simple_contract_user()
    object_data = {
        'contract': contract,
        'insuree': insuree,
        'contribution_plan_bundle': contribution_plan_bundle,
        'json_param': json.dumps("{}"),
        **custom_props
    }

    contract_details = ContractDetails(**object_data)
    contract_details.save(username=user.username)

    return contract_details
    def setUpClass(cls):
        if not User.objects.filter(username='******').exists():
            User.objects.create_superuser(username='******',
                                          password='******')
        cls.user = User.objects.filter(username='******').first()
        # some test data so as to created contract properly
        cls.income = 500
        cls.rate = 5
        cls.number_of_insuree = 2
        cls.policy_holder = create_test_policy_holder()
        cls.policy_holder2 = create_test_policy_holder()
        # create contribution plans etc
        cls.contribution_plan_bundle = create_test_contribution_plan_bundle()
        cls.contribution_plan = create_test_contribution_plan(custom_props={
            "json_ext":
            '{"calculation_rule":{"rate": "' + str(cls.rate) + '"}}'
        })
        cls.contribution_plan_bundle_details = create_test_contribution_plan_bundle_details(
            contribution_plan=cls.contribution_plan,
            contribution_plan_bundle=cls.contribution_plan_bundle)
        from core import datetime
        # create policy holder insuree for that test policy holder
        for i in range(0, cls.number_of_insuree):
            ph_insuree = create_test_policy_holder_insuree(
                policy_holder=cls.policy_holder,
                contribution_plan_bundle=cls.contribution_plan_bundle,
                custom_props={
                    "last_policy":
                    None,
                    "json_ext":
                    '{"calculation_rule":{"income": "' + str(cls.income) +
                    '"}}'
                })
            create_test_policy(cls.contribution_plan.benefit_plan,
                               ph_insuree.insuree,
                               custom_props={
                                   "start_date": datetime.datetime(2016, 3, 1),
                                   "expiry_date":
                                   datetime.datetime(2021, 7, 1)
                               })

        cls.policy_holder_insuree = create_test_policy_holder_insuree(
            policy_holder=cls.policy_holder,
            contribution_plan_bundle=cls.contribution_plan_bundle)
        cls.policy_holder_insuree2 = create_test_policy_holder_insuree(
            policy_holder=cls.policy_holder,
            contribution_plan_bundle=cls.contribution_plan_bundle)

        cls.schema = Schema(query=contract_schema.Query,
                            mutation=contract_schema.Mutation)
        cls.graph_client = Client(cls.schema)
 def setUpClass(cls):
     if not User.objects.filter(username='******').exists():
         User.objects.create_superuser(username='******',
                                       password='******')
     cls.user = User.objects.filter(username='******').first()
     cls.contribution_plan_service = ContributionPlanService(cls.user)
     cls.contribution_plan_bundle_service = ContributionPlanBundleService(
         cls.user)
     cls.contribution_plan_bundle_details_service = ContributionPlanBundleDetailsService(
         cls.user)
     cls.payment_plan_service = PaymentPlanService(cls.user)
     cls.test_product = create_test_product("PlanCode",
                                            custom_props={
                                                "insurance_period": 12,
                                            })
     cls.test_product2 = create_test_product(
         "PC", custom_props={"insurance_period": 6})
     cls.contribution_plan_bundle = create_test_contribution_plan_bundle()
     cls.contribution_plan = create_test_contribution_plan()
     cls.contribution_plan2 = create_test_contribution_plan()
     cls.calculation = ContributionValuationRule.uuid