def test_datapackage_is_correct(self): resources_paths = [ 'data/valid.csv', 'data/sequential_value.csv', ] dp = init_datapackage(resources_paths) assert dp is not None assert dp.valid, dp.errors assert len(dp.resources) == 2 actual_resources_paths = [res.descriptor['path'] for res in dp.resources] assert sorted(resources_paths) == sorted(actual_resources_paths)
def test_init_datapackage_is_correct(): resources_paths = [ 'data/valid.csv', 'data/sequential_value.csv', ] dp = init_datapackage(resources_paths) assert dp is not None assert dp.valid, dp.errors assert len(dp.resources) == 2 actual_resources_paths = [res.descriptor['path'] for res in dp.resources] assert sorted(resources_paths) == sorted(actual_resources_paths)
def init(paths, output, **kwargs): """Init data package from list of files. It will also infer tabular data's schemas from their contents. """ dp = goodtables.init_datapackage(paths) click.secho( json_module.dumps(dp.descriptor, indent=4), file=output ) exit(dp.valid) # Just to be defensive, as it should always be valid.