コード例 #1
0
def test_add_prerequisites_competency(work_based_input_kwargs):
    input_kwargs = {"competency_required": "Valid driver’s license"}

    expected_output = {
        "programPrerequisites": {
            "@type": "EducationalOccupationalCredential",
            "competencyRequired": "Valid driver’s license"
        }
    }

    output = add_prerequisites_data({}, input_kwargs)

    json_expected_output = json.dumps(expected_output, sort_keys=True)
    json_output = json.dumps(output, sort_keys=True)

    expect(json_output).to(equal(json_expected_output))
コード例 #2
0
def test_add_prerequisites_credential(work_based_input_kwargs):
    input_kwargs = {"credential_category": "HighSchool"}

    expected_output = {
        "programPrerequisites": {
            "@type": "EducationalOccupationalCredential",
            "credentialCategory": "HighSchool"
        }
    }

    output = add_prerequisites_data({}, input_kwargs)

    json_expected_output = json.dumps(expected_output, sort_keys=True)
    json_output = json.dumps(output, sort_keys=True)

    expect(json_output).to(equal(json_expected_output))
コード例 #3
0
def test_add_prerequisites_data(work_based_input_kwargs):
    input_kwargs = work_based_input_kwargs["program_prerequisites"]

    expected_output = {
        "programPrerequisites": {
            "@type":
            "EducationalOccupationalCredential",
            "credentialCategory":
            work_based_input_kwargs["program_prerequisites"]
            ["credential_category"],
            "competencyRequired":
            work_based_input_kwargs["program_prerequisites"]
            ["competency_required"]
        }
    }

    output = add_prerequisites_data({}, input_kwargs)

    json_expected_output = json.dumps(expected_output, sort_keys=True)
    json_output = json.dumps(output, sort_keys=True)

    expect(json_output).to(equal(json_expected_output))
    "offers_price",
    "provider_name",
    "provider_url",
    "provider_telephone",
    "time_to_complete",
]

kwarg_to_schema_key_mapper = {
    "program_description": "description",
    "program_name": "name",
    "program_url": "url"
}

data_keywords_mapper = {
    "program_prerequisites":
    lambda output, kwargs: add_prerequisites_data(
        output, kwargs.get('program_prerequisites')),
    "offers_price":
    lambda output, kwargs: add_offers_data(output, kwargs['offers_price']),
    "all": [
        lambda output, kwargs: add_header(output,
                                          "EducationalOccupationalProgram"),
        lambda output, kwargs: add_provider_data(output, kwargs),
        lambda output, kwargs: add_identifier_data(
            output, kwargs.get('identifier_cip'),
            kwargs.get('identifier_program_id'))
    ]
}


def educational_occupational_programs_converter(**kwargs):
    educational_occupational_programs_converter = Converter(
コード例 #5
0
# A list of keywords required for WorkBasedPrograms.
required_keywords = [
    "provider_address", "program_name", "program_description", "program_url",
    "occupational_category"
]

kwarg_to_schema_key_mapper = {
    "program_description": "description",
    "program_name": "name",
    "program_url": "url"
}

data_keywords_mapper = {
    "program_prerequisites":
    lambda output, kwargs: add_prerequisites_data(
        output, kwargs['program_prerequisites']),
    "offers_price":
    lambda output, kwargs: add_offers_data(output, kwargs['offers_price']),
    "training_salary":
    lambda output, kwargs: add_training_salary_data(output, kwargs[
        'training_salary']),
    "salary_upon_completion":
    lambda output, kwargs: add_salary_upon_completion_data(
        output, kwargs['salary_upon_completion']),
    "occupational_category":
    lambda output, kwargs: validate_occupational_category(
        output, kwargs["occupational_category"]),
    "all": [
        lambda output, kwargs: add_header(output, "WorkBasedProgram"),
        lambda output, kwargs: add_provider_data(output, kwargs)
    ]
コード例 #6
0
def test_add_data_keywords(work_based_input_kwargs, training_salary,
                           salary_upon_completion):
    data_keywords_mapper = {
        "program_prerequisites":
        lambda output, kwargs: add_prerequisites_data(
            output, kwargs["program_prerequisites"]),
        "offers_price":
        lambda output, kwargs: add_offers_data(output, kwargs["offers_price"]),
        "training_salary":
        lambda output, kwargs: add_training_salary_data(
            output, kwargs["training_salary"]),
        "salary_upon_completion":
        lambda output, kwargs: add_salary_upon_completion_data(
            output, kwargs["salary_upon_completion"]),
        "all": [
            lambda output, kwargs: add_header(output, "WorkBasedProgram"),
            lambda output, kwargs: add_provider_data(output, kwargs)
        ]
    }

    expected_output = {
        "@context": "http://schema.org/",
        "@type": "WorkBasedProgram",
        "offers": {
            "@type": "Offer",
            "category": "Total Cost",
            "priceSpecification": {
                "@type": "PriceSpecification",
                "price": work_based_input_kwargs["offers_price"],
                "priceCurrency": "USD"
            }
        },
        "programPrerequisites": {
            "@type":
            "EducationalOccupationalCredential",
            "credentialCategory":
            work_based_input_kwargs["program_prerequisites"]
            ["credential_category"],
            "competencyRequired":
            work_based_input_kwargs["program_prerequisites"]
            ["competency_required"]
        },
        "provider": {
            "@type":
            "EducationalOrganization",
            "name":
            work_based_input_kwargs['provider_name'],
            "address": [{
                "@type":
                "PostalAddress",
                "streetAddress":
                work_based_input_kwargs['provider_address'][0]
                ['street_address'],
                "addressLocality":
                work_based_input_kwargs['provider_address'][0]
                ['address_locality'],
                "addressRegion":
                work_based_input_kwargs['provider_address'][0]
                ['address_region'],
                "addressCountry":
                work_based_input_kwargs['provider_address'][0]
                ['address_country'],
                "postalCode":
                work_based_input_kwargs['provider_address'][0]['postal_code']
            }],
            "url":
            work_based_input_kwargs['provider_url'],
            "contactPoint": {
                "@type": "ContactPoint",
                "contactType": "Admissions",
                "telephone": work_based_input_kwargs['provider_telephone']
            }
        },
        "trainingSalary": training_salary,
        "salaryUponCompletion": salary_upon_completion
    }

    output = add_data_keywords({}, work_based_input_kwargs,
                               data_keywords_mapper)

    json_expected_output = json.dumps(expected_output, sort_keys=True)
    json_output = json.dumps(output, sort_keys=True)

    expect(json_output).to(equal(json_expected_output))
コード例 #7
0
def test_add_prerequisites_empty(work_based_input_kwargs):
    input_kwargs = {}
    expected_output = {}
    output = add_prerequisites_data({}, input_kwargs)

    expect(output).to(equal(expected_output))