Commit e2a7aee5 authored by Antoine Augusti's avatar Antoine Augusti
Browse files

Add test

parent 738aff47
Pipeline #1171 passed with stage
in 51 seconds
......@@ -61,6 +61,33 @@ def schema_number():
}
@pytest.fixture
def schema_siren():
return {
"$schema": "https://frictionlessdata.io/schemas/table-schema.json",
"fields": [
{
"name": "id",
"title": "id",
"type": "number"
},
{
"name": "siren",
"title": "Numéro SIREN",
"type": "string"
}
],
"custom_checks": [
{
"name": "french-siren-value",
"params": {
"column": "siren"
}
}
]
}
def validate_csv_text(**options):
return validate(scheme='text', format='csv', **options)
......@@ -220,6 +247,24 @@ a;c"""
assert report['tables'][0]['errors'][1]['code'] == 'missing-headers'
assert report['tables'][0]['errors'][1]['message-data']['headers'] == ['B']
def test_valid_custom_check_siren(schema_siren):
source = """id,siren
1,529173189"""
report = validate_csv_text(source=source, schema=schema_siren)
assert report['tables'][0]['error-count'] == 0
assert len(report['tables'][0]['errors']) == 0
def test_invalid_custom_check_siren(schema_siren):
source = """id,siren
1,529173188"""
report = validate_csv_text(source=source, schema=schema_siren)
assert report['tables'][0]['error-count'] == 1
assert len(report['tables'][0]['errors']) == 1
assert report['tables'][0]['errors'][0]['code'] == 'french-siren-value'
# XLSX
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment