Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Exposed preset and schema in report
Browse files Browse the repository at this point in the history
  • Loading branch information
roll committed Aug 9, 2017
1 parent ed58847 commit de65712
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ and `mock` packages. This packages are available only in tox environments.

Here described only breaking and the most important changes. The full changelog and documentation for all released versions could be found in nicely formatted [commit history](https://github.com/frictionlessdata/goodtables-py/commits/master).

### v1.2

New API added:
- `report.preset`
- `report.tables[].schema`

### v1.1

New API added:
Expand Down
2 changes: 2 additions & 0 deletions goodtables/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def inspect(self, source, preset='table', **options):
'table-count': len(tables),
'tables': table_reports,
'warnings': warnings,
'preset': preset,
}

return report
Expand Down Expand Up @@ -232,6 +233,7 @@ def __inspect_table(self, table):
'scheme': stream.scheme,
'format': stream.format,
'encoding': stream.encoding,
'schema': 'table-schema' if schema else None,
'errors': errors,
})

Expand Down
19 changes: 19 additions & 0 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,29 @@ def test_validate_infer_nested(log):
assert report['error-count'] == 7


# Report's preset

def test_validate_report_scheme_format_encoding():
report = validate('data/valid.csv')
assert report['preset'] == 'table'


# Report's scheme/format/encoding

def test_validate_report_scheme_format_encoding():
report = validate('data/valid.csv')
assert report['tables'][0]['scheme'] == 'file'
assert report['tables'][0]['format'] == 'csv'
assert report['tables'][0]['encoding'] == 'utf-8'


# Report's schema

def test_validate_report_schema():
report = validate('data/valid.csv')
assert report['tables'][0]['schema'] == None


def test_validate_report_schema_infer_schema():
report = validate('data/valid.csv', infer_schema=True)
assert report['tables'][0]['schema'] == 'table-schema'

0 comments on commit de65712

Please sign in to comment.