-
Notifications
You must be signed in to change notification settings - Fork 44
/
test_infer.py
35 lines (28 loc) · 1.09 KB
/
test_infer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest
from datapackage import infer
# Tests
def test_infer():
descriptor = infer('datapackage/*.csv', base_path='data')
assert descriptor == {
'profile': 'tabular-data-package',
'resources': [{'encoding': 'utf-8',
'format': 'csv',
'mediatype': 'text/csv',
'name': 'data',
'path': 'datapackage/data.csv',
'profile': 'tabular-data-resource',
'schema': {'fields': [
{'format': 'default', 'name': 'id', 'type': 'integer'},
{'format': 'default', 'name': 'city', 'type': 'string'}],
'missingValues': ['']}}]}
def test_infer_non_utf8_file():
descriptor = infer('data/data_with_accents.csv')
assert descriptor['resources'][0]['encoding'] == 'iso-8859-1'
def test_infer_empty_file():
descriptor = infer('data/empty.csv')
assert descriptor['resources'][0].get('encoding') is None