Beispiel #1
0
    def test_01_get_multi(self):
        """
        1. Get multiple.
        """

        the_user = User()
        the_user.get_multi()
Beispiel #2
0
 def test_02_get_one_user(self):
     """
     1. Choose a random, existing.
     2. Get only that one.
     """
     the_user = User()
     random_user = the_user.choose_random()
     the_user.get_one(random_user)
Beispiel #3
0
    def test_04_patch_one(self):
        """
        1. Choose random, required existing data.
        2. Create new.
        3. Get the newly created.
        4. Choose another random, required existing data.
        5. Update the created.
        6. Get the updates.
        """

        the_user = User()
        random_user = the_user.choose_random()
        json_user = the_user.post_one(random_user)
        json_user = the_user.get_one(json_user)
        the_user.patch_one(json_user)
        the_user.get_one(json_user)
Beispiel #4
0
def grab_post_json():
    """
    Grabs json for post endpoint.

    :return: json, the data.
    """

    user = User().choose_random()

    return json.dumps({
        "group_name": "group.test.x.{}".format(int(time.time())),
        "owner": {
            "id": user["id"]
        }
    })
Beispiel #5
0
    def test_03_post_one(self):
        """
        1. Choose random, required existing data.
        2. Create new.
        3. Get the newly created.
        """

        the_user = User()
        random_user = the_user.choose_random()
        json_user = the_user.post_one(random_user)
        the_user.get_one(json_user)
Beispiel #6
0
def grab_patch_json(origin_agent):
    """
    Grabs json for patch endpoint.

    :param origin_agent: json, the original.
    :return: json, the data.
    """

    the_name = "eapi.agent.test.x.{}".format(int(time.time()))
    the_image_url = "https://i.imgur.com/6eOsW2Z.gif"
    user = User().choose_random()

    return json.dumps({
        "external_id":
        "EDIT.{}".format(origin_agent["external_id"]),
        "email":
        origin_agent["email"],
        "username":
        "******".format(origin_agent["info"]["address"]),
        "info": {
            "address": "EDIT.{}".format(origin_agent["info"]["address"]),
            "first_name": "EDIT.{}".format(origin_agent["info"]["first_name"])
        },
        "settings_marketing": {
            "disclaimer":
            "EDIT.{}".format(origin_agent["settings_marketing"]["disclaimer"]),
            "profile_img_url":
            the_image_url
        },
        "licenses": [{
            "license_name": fake.grab_state_abbr(),
            "content": "EDIT.license.{}".format(the_name)
        }],
        "remove_licenses":
        fake.grab_one_from_old_json(origin_agent, target="licenses"),
        "connections":
        fake.grab_one_from_validated_array(user),
        "remove_connections":
        fake.grab_one_from_old_json(origin_agent, target="connections"),
        "settings_mls": {
            "mls_id":
            origin_agent["settings_mls"]["mls_id"],
            "mls_agent_id":
            "EDIT.{}".format(origin_agent["settings_mls"]["mls_agent_id"])
        }
    })
Beispiel #7
0
def grab_post_json():
    """
    Grabs json for post endpoint.

    :return: json, the data.
    """

    # This import being in here currently prevents recursive imports.
    #   Need a better way to handle this.
    from python.eapi.methods.users.user import User
    user = User().choose_random()
    the_name = "team.test.x.{}".format(int(time.time()))

    return json.dumps({
        "team_name": the_name,
        "managers": [{
            "id": user["id"]
        }]
    })
Beispiel #8
0
def grab_patch_json(origin_team):
    """
    Grabs json for patch endpoint.

    :param origin_team: json, the original.
    :return: json, the data.
    """

    # This import being in here currently prevents recursive imports.
    #   Need a better way to handle this.
    from python.eapi.methods.users.user import User
    user = User().choose_random()

    return json.dumps({
        "team_name": "EDIT." + origin_team["team_name"],
        "managers": [{
            "id": user["id"]
        }],
        "remove_managers": grab_old_managers(origin_team)
    })
Beispiel #9
0
def grab_patch_json(json_origin):
    """
    Grabs json for patch endpoint.

    :param json_origin: json, the original.
    :return: json, the data.
    """

    new_user = User().choose_random()
    new_borrower = json.loads(cohelp.grab_post_json(new_user, "borrower"))
    new_borrower.pop("options")
    new_coborrower = json.loads(cohelp.grab_post_json(new_user, "coborrower"))
    new_coborrower.pop("options")
    new_lprog = LoanProgram().choose_random()
    new_lpurp = LoanPurpose().choose_random()
    new_lstat = LoanStatus().choose_random()
    new_ltype = LoanType().choose_random()

    return json.dumps({
        "loan_name": "EDIT.{}".format(json_origin["loan_name"]),
        "owner": {
            "id": new_user["id"]
        },
        "loan_program": {
            "id": new_lprog["id"]
        },
        "loan_purpose": {
            "id": new_lpurp["id"]
        },
        "loan_status": {
            "id": new_lstat["id"]
        },
        "loan_type": {
            "id": new_ltype["id"]
        },
        "borrower": new_borrower,
        "coborrower": new_coborrower,
        "buyers_agent": new_coborrower,
        "sellers_agent": new_coborrower,
        "settlement_agent": new_coborrower
    })
Beispiel #10
0
def grab_post_json():
    """
    Grabs json for post endpoint.

    :return: json, the data.
    """

    the_time = int(time.time())
    the_name = "loan.test.x.{}".format(the_time)
    user = User().choose_random()
    borrower = json.loads(cohelp.grab_post_json(user, "borrower"))
    # Loans endpoint does not like it when its Loan Participants have "options".
    borrower.pop("options")
    coborrower = json.loads(cohelp.grab_post_json(user, "coborrower"))
    coborrower.pop("options")
    lprog = LoanProgram().choose_random()
    lpurp = LoanPurpose().choose_random()
    lstat = LoanStatus().choose_random()
    ltype = LoanType().choose_random()

    return json.dumps({
        "external_id": fake.grab_external_id(the_name),
        "loan_number": the_time,
        "loan_rate": fake.grab_decimal(),
        "loan_term": 360,
        "loan_application_number": the_time,
        "buydown_points": fake.grab_percent(),
        "monthly_pi_payment": fake.grab_money(),
        "monthly_pi_with_mi_payment": fake.grab_money(),
        "investor": fake.grab_company(),
        "debt_to_income": fake.grab_percent(),
        "closing_disclosure_out_date": fake.grab_fake_date(),
        "closing_disclosure_signed_date": fake.grab_fake_date(),
        "source": fake.grab_source(),
        "purchase_price": fake.grab_money(),
        "appraised_value": fake.grab_money(),
        "is_first_time_buyer": fake.grab_bool(),
        "property_type": fake.grab_word(),
        "address": fake.grab_address_one(),
        "address_2": fake.grab_address_two(),
        "city": fake.grab_city(),
        "state": fake.grab_state_abbr(),
        "zip_code": fake.grab_zip(),
        "county": fake.grab_word(),
        "loan_name": the_name,
        "pre_approval_issued": fake.grab_bool(),
        "loan_amount": fake.grab_money(),
        "loan_to_value_combined": fake.grab_percent(),
        "loan_to_value": fake.grab_percent(),
        "occupancy_type": fake.grab_phrase(),
        "estimated_value": fake.grab_money(),
        "lock_status": fake.grab_phrase(),
        "escrow_waived": fake.grab_bool(),
        "referral_source": fake.grab_source(),
        "annual_review_date": fake.grab_fake_date(),
        "application_date": fake.grab_fake_date(),
        "appraisal_expected_date": fake.grab_fake_date(),
        "appraisal_ordered_date": fake.grab_fake_date(),
        "appraisal_received_date": fake.grab_fake_date(),
        "approval_date": fake.grab_fake_date(),
        "closing_date": fake.grab_fake_date(),
        "created_date": fake.grab_fake_date(),
        "credit_report_date": fake.grab_fake_date(),
        "ctc_date": fake.grab_fake_date(),
        "documents_signed_date": fake.grab_fake_date(),
        "epo_date": fake.grab_fake_date(),
        "last_modified_date": fake.grab_fake_date(),
        "first_payment_date": fake.grab_fake_date(),
        "funded_date": fake.grab_fake_date(),
        "loan_arm_expiration_date": fake.grab_fake_date(),
        "lock_date": fake.grab_fake_date(),
        "lock_expiration_date": fake.grab_fake_date(),
        "pre_approval_expiration_date": fake.grab_fake_date(),
        "pre_approval_issued_date": fake.grab_fake_date(),
        "processing_start_date": fake.grab_fake_date(),
        "underwriting_approval_date": fake.grab_fake_date(),
        "underwriting_submission_date": fake.grab_fake_date(),
        "resubmittal_date": fake.grab_fake_date(),
        "audits_date": fake.grab_fake_date(),
        "docs_out_date": fake.grab_fake_date(),
        "funds_requested_date": fake.grab_fake_date(),
        "funding_date": fake.grab_fake_date(),
        "post_closed_date": fake.grab_fake_date(),
        "purchased_date": fake.grab_fake_date(),
        "completion_date": fake.grab_fake_date(),
        "lien_position": fake.grab_phrase(),
        "amort_type": fake.grab_phrase(),
        "amort_type_arm_desc": fake.grab_phrase(),
        "owner": {
            "id": user["id"]
        },
        "loan_program": {
            "id": lprog["id"]
        },
        "loan_purpose": {
            "id": lpurp["id"]
        },
        "loan_status": {
            "id": lstat["id"]
        },
        "loan_type": {
            "id": ltype["id"]
        },
        "credit_score": {
            "credit_score": fake.grab_small_int(),
            "scoring_agency": fake.grab_company(),
            "score_date": fake.grab_fake_date(),
        },
        "borrower": borrower,
        "coborrower": coborrower,
        "buyers_agent": coborrower,
        "sellers_agent": coborrower,
        "settlement_agent": coborrower,
        "options": {
            "suppress_emails": fake.grab_bool()
        }
    })
Beispiel #11
0
def grab_post_json():
    """
    Grabs json for post endpoint.

    :return: json, the data.
    """

    the_time = int(time.time())
    the_name = "eapi.agent.test.x.{}".format(the_time)
    the_image_url = "https://i.imgur.com/uGOD7Wr.jpg"
    user = User().choose_random()

    return json.dumps({
        "external_id":
        fake.grab_external_id(the_name),
        "email":
        fake.grab_email(the_name),
        "status":
        fake.grab_bool(),
        # "type" and "role" are optional; Agents are auto-assigned them.
        # TODO - Add in validation for fail scenario, on type and role.
        "info": {
            "address": fake.grab_address_one(),
            "address_2": fake.grab_address_two(),
            "city": fake.grab_city(),
            "state": fake.grab_state_abbr(),
            "zip_code": fake.grab_zip(),
            "first_name": fake.grab_first_name(),
            "last_name": fake.grab_last_name(),
            "phone_cell": fake.grab_phone(),
            "phone_fax": fake.grab_phone(),
            "phone_office": fake.grab_phone(),
            "job_title": fake.grab_job(),
            "cost_center": fake.grab_building_number(),
            "website": fake.grab_url(),
            "testimonial_url": fake.grab_url(),
            "timezone_name": fake.grab_timezone(),
            "location_id": fake.grab_building_number(),
            "company": fake.grab_company()
        },
        "settings_marketing": {
            "application_url": fake.grab_url(),
            "disclaimer": fake.grab_phrase(),
            "license_title": fake.grab_job(),
            "social_facebook": fake.grab_url(),
            "social_twitter": fake.grab_url(),
            "social_google": fake.grab_url(),
            "social_linkedin": fake.grab_url(),
            "social_youtube": fake.grab_url(),
            "weekly_spend_threshold": fake.grab_percent(),
            "daily_spend_threshold": fake.grab_percent() - 1.00,
            "agent_bio": fake.grab_phrase(),
            "short_name": "short.{}".format(fake.grab_username()),
            "post_close_survey_url": fake.grab_url(),
            "wistia_id": fake.grab_large_int(),
            "user_quote": fake.grab_phrase(),
            "profile_img_url": the_image_url,
            "logo_img_url": the_image_url
        },
        "licenses": [{
            "license_name": fake.grab_state_abbr(),
            "content": "license.{}".format(the_name)
        }],
        "connections":
        fake.grab_one_from_validated_array(user, "id"),
        "settings_mls": {
            "mls_id": the_time,
            "mls_agent_id": the_name
        }
    })
Beispiel #12
0
def grab_post_json(user=None, name="lead"):
    """
    Grabs json for post endpoint.

    :return: json, the data.
    """

    the_name = "{}.test.x.{}".format(name, int(time.time()))
    if user is None:
        user = User().choose_random()
    cgroup = ContactGroup().choose_random()

    return json.dumps(
        {
            "title": fake.grab_prefix(),
            "first_name": fake.grab_first_name(),
            "last_name": fake.grab_last_name(),
            "suffix": fake.grab_suffix(),
            "nickname": fake.grab_username(),
            "email": fake.grab_email(the_name),
            "email_work": "work.{}".format(fake.grab_email(the_name)),
            "ok_to_email": fake.grab_bool(),
            "address": fake.grab_address_one(),
            "address_2": fake.grab_address_two(),
            "city": fake.grab_city(),
            "state": fake.grab_state_abbr(),
            "zip_code": fake.grab_zip(),
            "ok_to_mail": fake.grab_bool(),
            "phone_cell": fake.grab_phone(),
            "phone_office": fake.grab_phone(),
            "phone_home": fake.grab_phone(),
            "ok_to_call": fake.grab_bool(),
            "employer_name": fake.grab_company(),
            "employer_address": fake.grab_address_one(),
            "employer_address_2": fake.grab_address_two(),
            "employer_city": fake.grab_city(),
            "employer_state": fake.grab_state_abbr(),
            "employer_zip": fake.grab_zip(),
            "employer_license_number": fake.grab_large_int(),
            "license_number": fake.grab_large_int(),
            "source": fake.grab_source(),
            "last_modified_date": fake.grab_fake_date(),
            "creation_date": fake.grab_fake_date(),
            "last_contacted_date": fake.grab_fake_date(),
            "referred_to": fake.grab_full_name(),
            "referred_by": fake.grab_full_name(),
            "classification": fake.grab_large_int(),
            "list_date": fake.grab_fake_date(),
            "close_date": fake.grab_fake_date(),
            "external_id": fake.grab_external_id(the_name),
            "credit_score": fake.grab_credit_score(),
            "birthday": fake.grab_fake_date(),
            "credit_score_date": fake.grab_fake_date(),
            "credit_score_expiration_date": fake.grab_fake_date(),
            "linkedin_url": fake.grab_url(),
            "website_url": fake.grab_url(),
            "other_url": fake.grab_url(),
            "fax": fake.grab_phone(),
            "owner": {
                "id": user["id"]
            },
            "external_status": {
                "status_name": fake.grab_external_status(the_name)
            },
            "contact_groups": fake.grab_one_from_validated_array(cgroup,
                                                                 "group_name"),
            "external_ids": [
                {
                    "source": fake.grab_source(),
                    "external_id": fake.grab_external_status(the_name,
                                                             "relationships")
                }
            ],
            "preferences": {
                "is_silenced": fake.grab_bool()
            },
            "options": {
                "suppress_emails": fake.grab_bool()
            }
        }
    )