Commit e35e3c8b authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Initial commit

parents
Pipeline #2337 failed with stages
in 12 minutes and 34 seconds
autoflake
black
flake8
flake8-bandit
flake8-black
flake8-blind-except
flake8-builtins
flake8-comprehensions
flake8-docstrings
flake8-isort
flake8-logging-format
flake8-mutable
flake8-rst-docstrings
ipdb
ipython
isort
mypy
pytest
frictionless
\ No newline at end of file
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile
#
attrs==20.3.0 # via jsonschema
certifi==2020.11.8 # via requests
chardet==3.0.4 # via frictionless, requests
click==7.1.2 # via frictionless
et-xmlfile==1.0.1 # via openpyxl
frictionless==3.29.0 # via -r requirements.in
idna==2.10 # via requests
ijson==3.1.2.post0 # via frictionless
isodate==0.6.0 # via frictionless
jdcal==1.4.1 # via openpyxl
jsonlines==1.2.0 # via frictionless
jsonschema==3.2.0 # via frictionless
openpyxl==3.0.5 # via frictionless
petl==1.6.8 # via frictionless
pyrsistent==0.17.3 # via jsonschema
python-dateutil==2.8.1 # via frictionless
python-slugify==4.0.1 # via frictionless
pyyaml==5.3.1 # via frictionless
requests==2.25.0 # via frictionless
rfc3986==1.4.0 # via frictionless
simpleeval==0.9.10 # via frictionless
simplejson==3.17.2 # via frictionless
six==1.15.0 # via isodate, jsonlines, jsonschema, python-dateutil
stringcase==1.2.0 # via frictionless
text-unidecode==1.3 # via python-slugify
unicodecsv==0.14.1 # via frictionless
urllib3==1.26.2 # via requests
xlrd==1.2.0 # via frictionless
xlwt==1.3.0 # via frictionless
# The following packages are considered to be unsafe in a requirements file:
# setuptools
[flake8]
# From https://pypi.org/project/flake8-black/
# Recommend matching the black line length (default 88),
# rather than using the flake8 default of 79:
max-line-length = 88
extend-ignore =
E203, # See https://github.com/PyCQA/pycodestyle/issues/373
D202, # See https://github.com/PyCQA/pydocstyle/pull/395
enable-extensions=G # for flake8-logging-format
[isort]
# From https://black.readthedocs.io/en/stable/the_black_code_style.html#how-black-wraps-lines
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 88
[pycodestyle]
max_line_length = 88
[doc8]
max-line-length = 88
[tool:pytest]
addopts = --doctest-modules
Name,Email,Age
Jill,jill@foo.com,25
Jack,jack@bar.com,33
\ No newline at end of file
{
"fields": [
{
"name": "Name",
"type": "string",
"description": "User’s name"
},
{
"name": "Email",
"type": "string",
"format": "email",
"description": "User’s email"
},
{
"name": "Age",
"type": "integer",
"description": "User’s age",
"constraints": {
"minimum": 18
}
}
]
}
\ No newline at end of file
from pathlib import Path
import pytest
from frictionless import validate_table, Schema, Table
from frictionless.exceptions import FrictionlessException
script_dir = Path(__file__).resolve().parent
@pytest.fixture
def simple_contact_schema_path():
return script_dir / "fixtures" / "simple_contact_schema.json"
@pytest.fixture
def simple_contact_csv_path():
return script_dir / "fixtures" / "simple_contact.csv"
def test_simple_schema(simple_contact_schema_path):
assert simple_contact_schema_path.exists()
schema = Schema(str(simple_contact_schema_path))
def test_get_descriptor(simple_contact_schema_path):
schema = Schema(str(simple_contact_schema_path))
try:
# There's no schema.descriptor anymore
field_list = schema.descriptor.get("fields")
assert False
except AttributeError:
pass
# Descriptor can be directly accessed from schema instance
field_list = schema.get("fields")
def test_validate_csv(simple_contact_schema_path, simple_contact_csv_path):
schema = Schema(str(simple_contact_schema_path))
# validate_table replaces inspector.inspect
report = validate_table(str(simple_contact_csv_path), schema=schema)
def test_tabulator_stream(simple_contact_csv_path):
# Below code replace
# stream = tabulator.stream.Stream(source, **options)
# stream.open()
# headers = next(stream.iter())
# body_rows = list(stream.iter())
stream = Table(str(simple_contact_csv_path))
stream.open()
headers = stream.header
assert len(headers) == 3
body_rows = list(stream.data_stream)
assert len(body_rows) == 2
for row in body_rows:
assert len(row) == len(headers)
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