Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Antoine Augusti
Validata Core
Commits
e2a7aee5
Commit
e2a7aee5
authored
Jul 01, 2019
by
Antoine Augusti
Browse files
Add test
parent
738aff47
Pipeline
#1171
passed with stage
in 51 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/test_core.py
View file @
e2a7aee5
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment