Esempio n. 1
0
def test_schema_add_remove_field_issue_218():
    descriptor = {
        "fields": [
            {
                "name": "test_1",
                "type": "string",
                "format": "default"
            },
            {
                "name": "test_2",
                "type": "string",
                "format": "default"
            },
            {
                "name": "test_3",
                "type": "string",
                "format": "default"
            },
        ]
    }
    test_schema = Schema(descriptor)
    test_schema.remove_field("test_1")
    test_schema.add_field({
        "name": "test_4",
        "type": "string",
        "format": "default"
    })
Esempio n. 2
0
def generate_schema(
    base="static/base-schema.json",
    outfile="static/schema.json",
    repository="",
):
    table_schema = Schema(base)
    table_schema["path"] = repository + "schema.json"
    table_schema.get(
        "resources")[0]["path"] = repository + "exemple-valide.csv"

    # table_schema["version"] = "0.0.1"

    for field_name in EtalabMapper.headers():
        f = FIELDS.get(field_name)
        if not f:
            continue

        table_schema.add_field(create_field(field_name, f))

    table_schema.to_json(outfile)
Esempio n. 3
0
def test_schema_add_then_remove_field():
    schema = Schema()
    schema.add_field({"name": "name"})
    field = schema.remove_field("name")
    assert field.name == "name"