コード例 #1
0
def test_missing_ids(endpoint):
    example_response = get_example_response(f"{endpoint}.json")

    del example_response["result"]["id"]

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, endpoint)
コード例 #2
0
def test_search_dataset_pii_extra():
    example_response = get_example_response("search_dataset.all_fields.json")

    example_response["results"][1]["extras"]["author"] = "Rieux"

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, "search_dataset")
コード例 #3
0
def test_organization_show_is_organization():
    example_response = get_example_response("organization_show.json")

    example_response["result"]["is_organization"] = False

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, "organization_show")
コード例 #4
0
def test_format_autocomplete_result_missing_format():
    example_response = get_example_response("format_autocomplete.json")

    del example_response["ResultSet"]["Result"][1]["Format"]

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, "format_autocomplete")
コード例 #5
0
def test_package_search_pii_field():
    example_response = get_example_response("package_search.json")

    example_response["result"]["results"][1]["author"] = "Rieux"

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, "package_search")
コード例 #6
0
def test_package_search_empty_tag():
    example_response = get_example_response("package_search.json")

    example_response["result"]["results"][2]["tags"].append({})

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, "package_search")
コード例 #7
0
def test_unknown_state(endpoint):
    example_response = get_example_response(f"{endpoint}.json")

    example_response["result"]["state"] = "lockdown"

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, endpoint)
コード例 #8
0
def stable_org(inc_fixed_data):
    return _strip_unstable_data(
        clean_unstable_elements(
            get_example_response(
                "stable/organization_show.inner.test.json"
            )
        )
    )
コード例 #9
0
def test_package_search_noninteger_facet():
    example_response = get_example_response("package_search.json")

    example_response["result"]["facets"]["organization"][
        "natural-england"] = "2"

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, "package_search")
コード例 #10
0
def test_package_show_org_must_follow_org_schema():
    example_response = get_example_response("package_show.json")

    # note non-existent leap-day
    example_response["result"]["organization"][
        "created"] = "2019-02-29T16:00:00.123Z"

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, "package_show")
コード例 #11
0
def test_package_search_pii_extra():
    example_response = get_example_response("package_search.json")

    example_response["result"]["results"][1]["extras"].append({
        "key": "author",
        "value": "Rieux"
    })

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, "package_search")
コード例 #12
0
def stable_pkg_default_schema(variables, inc_fixed_data):
    json_data = get_example_response(
        "stable/package_show.default_schema.inner.test.json"
    )

    return set_ckan_vars(json_data)
コード例 #13
0
def stable_pkg_search(variables, inc_fixed_data):
    return set_ckan_vars(
        clean_unstable_elements(
            get_example_response("stable/package_search.inner.test.json")
        )
    )
コード例 #14
0
def test_responses_pass_respective_schemas(response_filename, schema_name):
    validate_against_schema(get_example_response(response_filename),
                            schema_name)
コード例 #15
0
def stable_org_with_datasets(variables, inc_fixed_data):
    return set_ckan_vars(get_example_response(
        "stable/organization_show_with_datasets.inner.test.json"
    ))
コード例 #16
0
def stable_dataset(variables, inc_fixed_data):
    return set_ckan_vars(
        get_example_response(
        "stable/search_dataset{}.inner.test.json".format('-2.9' if variables['ckan_version'] == '2.9' else '')
        )
    )
コード例 #17
0
def test_package_list_must_be_slugs(nonslug_value):
    example_response = get_example_response("package_list.json")
    example_response["result"][2] = nonslug_value

    with pytest.raises(jsonschema.ValidationError):
        validate_against_schema(example_response, "package_list")