forked from singer-io/singer-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_catalog.py
More file actions
79 lines (71 loc) · 2.55 KB
/
test_catalog.py
File metadata and controls
79 lines (71 loc) · 2.55 KB
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
import unittest
from singer.schema import Schema
from singer.catalog import Catalog, CatalogEntry
class TestToDictAndFromDict(unittest.TestCase):
dict_form = {
'streams': [
{
'stream': 'users',
'tap_stream_id': 'prod_users',
'database_name': 'prod',
'table_name': 'users',
'schema': {
'type': 'object',
'selected': True,
'properties': {
'id': {'type': 'integer', 'selected': True},
'name': {'type': 'string', 'selected': True}
}
},
},
{
'stream': 'orders',
'tap_stream_id': 'prod_orders',
'database_name': 'prod',
'table_name': 'orders',
'schema': {
'type': 'object',
'selected': True,
'properties': {
'id': {'type': 'integer', 'selected': True},
'amount': {'type': 'number', 'selected': True}
}
}
}
]
}
obj_form = Catalog(streams=[
CatalogEntry(
stream='users',
tap_stream_id='prod_users',
database='prod',
table='users',
schema=Schema(
type='object',
selected=True,
properties={
'id': Schema(type='integer', selected=True),
'name': Schema(type='string', selected=True)})),
CatalogEntry(
stream='orders',
tap_stream_id='prod_orders',
database='prod',
table='orders',
schema=Schema(
type='object',
selected=True,
properties={
'id': Schema(type='integer', selected=True),
'amount': Schema(type='number', selected=True)}))])
def test_from_dict(self):
self.assertEqual(self.obj_form, Catalog.from_dict(self.dict_form))
def test_to_dict(self):
self.assertEqual(self.dict_form, self.obj_form.to_dict())
class TestGetStream(unittest.TestCase):
def test(self):
catalog = Catalog(
[CatalogEntry(tap_stream_id='a'),
CatalogEntry(tap_stream_id='b'),
CatalogEntry(tap_stream_id='c')])
entry = catalog.get_stream('b')
self.assertEquals('b', entry.tap_stream_id)