-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
91 lines (84 loc) · 2.72 KB
/
tests.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from __future__ import unicode_literals
from unittest import TestCase
from coblr import Coblr, Schema
class TestCoblr(TestCase):
def setUp(self):
self.database_name = 'foodb'
self.schema_directory = 'schema'
self.coblr = Coblr(self.database_name, self.schema_directory)
def test_contruct_schema_from_filesystem(self):
expected_schema = {
u'ns1': {
u'transactions': {
u'columns': [
'status',
'description',
'created_at',
'funding_instrument_id',
'amount',
'customer_id',
'type',
'id'
]
}
},
u'ns2': {
u'transactions': {
u'columns': [
'status',
'description',
'created_at',
'funding_instrument_id',
'amount',
'customer_id',
'type',
'id']
}
}
}
result = self.coblr.construct_schema_from_filesystem(self.schema_directory)
for ns in result:
for table in result[ns]:
result[ns][table].pop('files')
self.assertEqual(result, expected_schema)
def test_schema_from_dict(self):
dikt = {
u'ns1': {
u'transactions': {
u'columns': [
'status',
'description',
'created_at',
'funding_instrument_id',
'amount',
'customer_id',
'type',
'id'
],
u'files': [
u'txns1.csv',
u'txns2.csv'
]
}
},
u'ns2': {
u'transactions': {
u'columns': [
'status',
'description',
'created_at',
'funding_instrument_id',
'amount',
'customer_id',
'type',
'id'],
u'files': [
u'txns1.csv',
u'txns2.csv'
]
}
}
}
schema = Schema(dikt)
def test_create_database(self):
self.coblr.create_database()