def test_get_post_put_patch_on_one_item(regular_client):
    # Get
    body = ApiHelper.get_credential(regular_client)
    expect(body["credentials"]).to(be_empty)
    expect(body["links"]).to(be_empty)

    # Post
    post_body = {"credential_name": "testtesttest"}
    credential_id = ApiHelper.post_a_credential(regular_client, post_body)

    body = ApiHelper.get_credential(regular_client)
    expect(len(body["credentials"])).to(equal(1))

    body = ApiHelper.get_credential(regular_client, credential_id)
    expect(body["credential_name"]).to(equal("testtesttest"))

    # Put
    put_body = {"credential_name": "asdf"}
    ApiHelper.put_a_credential(regular_client, put_body, credential_id)
    body = ApiHelper.get_credential(regular_client, credential_id)

    expect(body["credential_name"]).to(equal("asdf"))

    # Patch
    patch_body = {"credential_name": "qwery"}
    ApiHelper.patch_a_credential(regular_client, patch_body, credential_id)
    body = ApiHelper.get_credential(regular_client, credential_id)

    expect(body["credential_name"]).to(equal("qwery"))
Пример #2
0
def test_load_descriptor(frameworks_skills_client):
    c = frameworks_skills_client
    skill_1 = ApiHelper.post_a_skill(c, "skill1")
    skill_2 = ApiHelper.post_a_skill(c, "skill2")
    skills_list = [skill_1, skill_2]
    framework_id = ApiHelper.post_a_framework(c, skills_list)

    ApiHelper.check_for_skills_on_framework(c, framework_id, skills_list)
Пример #3
0
def test_mn_reverse_relationship(frameworks_skills_client):
    c = frameworks_skills_client

    skill_1 = ApiHelper.post_a_skill(c, "skill1")
    framework_id = ApiHelper.post_a_framework(c, [skill_1])

    resp = ApiHelper.get_frameworks_on_skill(c, skill_1)

    expect(resp["frameworks"]).to(equal([framework_id]))
def run_query(client, key, value, expected_value=None):
    if not expected_value:
        expected_value = value
    post_body = {key: value}
    id_ = ApiHelper.everything_post(ROUTE, client, post_body)
    resp_data = ApiHelper.everything_get(ROUTE, client, id_)
    resp = json.loads(resp_data)

    expect(resp[key]).to(equal(expected_value))
    assert type(resp[key]) == type(expected_value)
Пример #5
0
def test_mn_delete_one(frameworks_skills_client):
    c = frameworks_skills_client

    skill_1 = ApiHelper.post_a_skill(c, "skill1")
    skill_2 = ApiHelper.post_a_skill(c, "skill2")
    skills_list = [skill_1, skill_2]

    framework_id = ApiHelper.post_a_framework(c, skills_list)
    resp = ApiHelper.delete_a_framework_skill(c, framework_id, [skill_1])

    expect(resp["skills"]).to(equal([skill_2]))
def test_json_posts_and_returns_correctly(json_client):
    c = json_client

    json_body = {"test": 1234, "obj": {"key": "value"}}

    json_id = ApiHelper.post_a_json(c, json_body)

    resp = ApiHelper.get_a_json_by_id(c, json_id)

    expect(json.dumps(resp["json"], sort_keys=True)).to(
        equal(json.dumps(json_body, sort_keys=True))
    )
Пример #7
0
def test_mn_delete_relationship_that_does_not_exist(frameworks_skills_client):
    c = frameworks_skills_client

    skill_1 = ApiHelper.post_a_skill(c, "skill1")
    skill_2 = ApiHelper.post_a_skill(c, "skill2")
    skill_3 = ApiHelper.post_a_skill(c, "skill3")
    skills_list = [skill_1, skill_2]
    framework_id = ApiHelper.post_a_framework(c, skills_list)

    resp = ApiHelper.delete_a_framework_skill(c, framework_id, [skill_3])

    expect(resp["skills"]).to(equal([skill_1, skill_2]))
def test_long_str(json_client):
    c = json_client

    json_body = {
        "data": '{"uuid": "e997a2f7-2809-4543-b55e-edff65d66c62", "first_name": "Aniya", "last_name": "Sauer", "gender": "Female/Woman", "email": "*****@*****.**", "phone": null, "phone_type": null, "resume": null, "street": null, "street2": null, "city": null, "state": null, "zipcode": null, "country": "US", "birthdate": "1990-12-12", "highest_education": null, "work_authorized": true, "preferred_language": "english", "unemployment_insurance": null, "race": null, "selective_service": null, "veteran": "{\\"non_veteran\\": true}", "created_at": "2019-10-01 08:45:35 -0600", "last_login": "", "journey_role": null, "ssn_last4": null, "high_school_graduation_year": null, "associated_organization": null, "legacy_data_consent": null, "work_histories": [], "most_recent_completed_assessment": null, "user_employment": {"currently_employed": null, "laid_off": null, "mass_layoff": null, "fired": null, "changing_careers": null, "current_industry": null, "seasonal": true}, "military_histories": [], "certifications": [], "education_histories": [], "language_proficiency": [], "user_question_data": {"job_difficulties": null, "assistance": null, "looking_for": "{\\"job\\": true}", "va_benefits": null, "homeless_risk": null, "incarcerated": null, "divorced": null, "looking_change_self_employment": null, "low_income": null, "housing_situation": null, "satisfied_income": null, "aspired_education": null, "education_training_info": null}'
    }

    json_id = ApiHelper.post_a_json(c, json_body)

    resp = ApiHelper.get_a_json_by_id(c, json_id)

    expect(json.dumps(resp["json"], sort_keys=True)).to(
        equal(json.dumps(json_body, sort_keys=True))
    )
Пример #9
0
def test_relationships(frameworks_skills_client):
    c = frameworks_skills_client

    def get_wrong_relationship(framework_id: int):
        route = f"/frameworks/{framework_id}/providers"
        response = frameworks_skills_client.get(route)
        body = json.loads(response.data)

        expect(response.status_code).to(equal(404))

        error_message = "Location not found"
        expect(body["error"]).to(equal(error_message))

    def get_nonexistant_relationship(framework_id: int):
        route = f"/frameworks/{framework_id}/skills"
        response = frameworks_skills_client.get(route)

        body = json.loads(response.data)
        print(body)

        expect(response.status_code).to(equal(200))
        expect(len(body["skills"])).to(equal(0))

    framework_id = ApiHelper.post_a_framework_with_no_skills(c)
    get_wrong_relationship(framework_id)
    get_nonexistant_relationship(framework_id)
Пример #10
0
def test_mn_put(frameworks_skills_client):
    c = frameworks_skills_client

    skill_1 = ApiHelper.post_a_skill(c, "skill1")
    skill_2 = ApiHelper.post_a_skill(c, "skill2")
    skills_list = [skill_1, skill_2]
    skill_3 = ApiHelper.post_a_skill(c, "skill3")
    framework_id = ApiHelper.post_a_framework(c, skills_list)

    ApiHelper.put_a_framework_skill(c, framework_id, [skill_3])
    ApiHelper.check_for_skills_on_framework(c, framework_id, [skill_3])
def test_pagination(regular_client):
    post_body = {"credential_name": "testtesttest"}
    _ = ApiHelper.post_a_credential(regular_client, post_body)

    # Check that we have items?
    body = ApiHelper.get_credential(regular_client)
    expect(len(body["credentials"])).not_to(equal(0))

    # do get with pagination
    _ = ApiHelper.get_credential(regular_client, None, "?offset=0&limit=20")
    # add items till we need the pagination
    for _ in range(100):
        post_body = {"credential_name": "testtesttest"}
        _ = ApiHelper.post_a_credential(regular_client, post_body)

    # do get with pagination
    body = ApiHelper.get_credential(regular_client, None, "?offset=0&limit=20")
    expect(len(body["credentials"])).to(equal(20))

    # do get with pagination
    body = ApiHelper.get_credential(regular_client, None,
                                    "?offset=20&limit=20")
    expect(len(body["credentials"])).to(equal(20))
def test_programs(regular_client):
    _ = ApiHelper.get_program(regular_client)
def test_error_on_nonexistant_field(regular_client):
    post_body = {
        "credential_name": "test credential",
        "doesnotexist": "doesnotexist data",
    }
    ApiHelper.post_a_credential(regular_client, post_body, 400)