File: test_chain.py

package info (click to toggle)
python-stetl 1.0.9%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 89,428 kB
  • ctags: 720
  • sloc: python: 3,527; xml: 699; sql: 428; makefile: 153; sh: 45
file content (213 lines) | stat: -rw-r--r-- 8,949 bytes parent folder | download | duplicates (2)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# testing: to be called by nosetests

import logging
import sys
import unittest

from stetl.etl import ETL

logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)


class ConfigTest(unittest.TestCase):
    """Basic configuration tests"""

    def test_type(self):
        cfg_dict = {'config_file': 'tests/configs/copy_in_out.cfg'}
        etl = ETL(cfg_dict)
        self.failUnlessEqual(etl.configdict.get('etl', 'chains'), 'input_xml_file|output_std')


#        etl.run()
#
# def main():
#     # Test file listing
#     cand_file = sys.argv[1]
#     file_list = Util.make_file_list(cand_file)
#     print(str(file_list))
#
#
# if __name__ == "__main__":
#     main()
#

# def geometry_wkb(wkb):
#     return GeomBuilder().build_wkb(wkb)
#
#
# class OGRBuilderExceptionsTest(unittest.TestCase):
#     def test(self):
#         geom = {'type': "Bogus", 'coordinates': None}
#         self.assertRaises(ValueError, geometryRT, geom)

# The round tripping tests are defined in this not to be run base class.
#
# class RoundTripping(object):
#     """Derive type specific classes from this."""
#     def test_type(self):
#         self.failUnlessEqual(
#             geometryRT(self.geom)['type'], self.geom['type'])
#     def test_coordinates(self):
#         self.failUnlessEqual(
#             geometryRT(self.geom)['coordinates'], self.geom['coordinates'])
#
# # All these get their tests from the RoundTripping class.
# #
# class PointRoundTripTest(unittest.TestCase, RoundTripping):
#     def setUp(self):
#         self.geom = {'type': "Point", 'coordinates': (0.0, 0.0)}
#
# class LineStringRoundTripTest(unittest.TestCase, RoundTripping):
#     def setUp(self):
#         self.geom = {
#             'type': "LineString",
#             'coordinates': [(0.0, 0.0), (1.0, 1.0)]}
#
# class PolygonRoundTripTest1(unittest.TestCase, RoundTripping):
#     """An explicitly closed polygon."""
#     def setUp(self):
#         self.geom = {
#             'type': "Polygon",
#             'coordinates': [
#                 [(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)]]}
#
# class PolygonRoundTripTest2(unittest.TestCase, RoundTripping):
#     """An implicitly closed polygon."""
#     def setUp(self):
#         self.geom = {
#             'type': "Polygon",
#             'coordinates': [
#                 [(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)]]}
#     def test_coordinates(self):
#         self.failUnlessEqual(
#             [geometryRT(self.geom)['coordinates'][0][:-1]],
#             self.geom['coordinates'])
#
# class MultiPointRoundTripTest(unittest.TestCase, RoundTripping):
#     def setUp(self):
#         self.geom = {
#             'type': "MultiPoint", 'coordinates': [(0.0, 0.0), (1.0, 1.0)]}
#
# class MultiLineStringRoundTripTest(unittest.TestCase, RoundTripping):
#     def setUp(self):
#         self.geom = {
#             'type': "MultiLineString",
#             'coordinates': [[(0.0, 0.0), (1.0, 1.0)]]}
#
# class MultiPolygonRoundTripTest1(unittest.TestCase, RoundTripping):
#     def setUp(self):
#         # This is an explicitly closed polygon.
#         self.geom = {
#             'type': "MultiPolygon",
#             'coordinates': [[
#                 [(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)]
#                 ]]}
#
# class MultiPolygonRoundTripTest2(unittest.TestCase, RoundTripping):
#     def setUp(self):
#         # This is an implicitly closed polygon.
#         self.geom = {
#             'type': "MultiPolygon",
#             'coordinates':
#                 [[[(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)]]]}
#     def test_coordinates(self):
#         self.failUnlessEqual(
#             [[geometryRT(self.geom)['coordinates'][0][0][:-1]]],
#             self.geom['coordinates'])
#
# class GeometryCollectionRoundTripTest(unittest.TestCase):
#     def setUp(self):
#         self.geom = {
#             'type': "GeometryCollection",
#             'geometries': [
#                 {'type': "Point", 'coordinates': (0.0, 0.0)}, {
#                     'type': "LineString",
#                     'coordinates': [(0.0, 0.0), (1.0, 1.0)]}]}
#     def test_len(self):
#         result = geometryRT(self.geom)
#         self.failUnlessEqual(len(result['geometries']), 2)
#     def test_type(self):
#         result = geometryRT(self.geom)
#         self.failUnlessEqual(
#             [g['type'] for g in result['geometries']],
#             ['Point', 'LineString'])
#
# class PointTest(unittest.TestCase):
#     def test_point(self):
#         # Hex-encoded Point (0 0)
#         try:
#             wkb = bytes.fromhex("010100000000000000000000000000000000000000")
#         except:
#             wkb = "010100000000000000000000000000000000000000".decode('hex')
#         geom = geometry_wkb(wkb)
#         self.failUnlessEqual(geom['type'], "Point")
#         self.failUnlessEqual(geom['coordinates'], (0.0, 0.0))
#
# class LineStringTest(unittest.TestCase):
#     def test_line(self):
#         # Hex-encoded LineString (0 0, 1 1)
#         try:
#             wkb = bytes.fromhex("01020000000200000000000000000000000000000000000000000000000000f03f000000000000f03f")
#         except:
#             wkb = "01020000000200000000000000000000000000000000000000000000000000f03f000000000000f03f".decode('hex')
#         geom = geometry_wkb(wkb)
#         self.failUnlessEqual(geom['type'], "LineString")
#         self.failUnlessEqual(geom['coordinates'], [(0.0, 0.0), (1.0, 1.0)])
#
# class PolygonTest(unittest.TestCase):
#     def test_polygon(self):
#         # 1 x 1 box (0, 0, 1, 1)
#         try:
#             wkb = bytes.fromhex("01030000000100000005000000000000000000f03f0000000000000000000000000000f03f000000000000f03f0000000000000000000000000000f03f00000000000000000000000000000000000000000000f03f0000000000000000")
#         except:
#             wkb = "01030000000100000005000000000000000000f03f0000000000000000000000000000f03f000000000000f03f0000000000000000000000000000f03f00000000000000000000000000000000000000000000f03f0000000000000000".decode('hex')
#         geom = geometry_wkb(wkb)
#         self.failUnlessEqual(geom['type'], "Polygon")
#         self.failUnlessEqual(len(geom['coordinates']), 1)
#         self.failUnlessEqual(len(geom['coordinates'][0]), 5)
#         x, y = zip(*geom['coordinates'][0])
#         self.failUnlessEqual(min(x), 0.0)
#         self.failUnlessEqual(min(y), 0.0)
#         self.failUnlessEqual(max(x), 1.0)
#         self.failUnlessEqual(max(y), 1.0)
#
# class MultiPointTest(unittest.TestCase):
#     def test_multipoint(self):
#         try:
#             wkb = bytes.fromhex("0104000000020000000101000000000000000000000000000000000000000101000000000000000000f03f000000000000f03f")
#         except:
#             wkb = "0104000000020000000101000000000000000000000000000000000000000101000000000000000000f03f000000000000f03f".decode('hex')
#         geom = geometry_wkb(wkb)
#         self.failUnlessEqual(geom['type'], "MultiPoint")
#         self.failUnlessEqual(geom['coordinates'], [(0.0, 0.0), (1.0, 1.0)])
#
# class MultiLineStringTest(unittest.TestCase):
#     def test_multilinestring(self):
#         # Hex-encoded LineString (0 0, 1 1)
#         try:
#             wkb = bytes.fromhex("01050000000100000001020000000200000000000000000000000000000000000000000000000000f03f000000000000f03f")
#         except:
#             wkb = "01050000000100000001020000000200000000000000000000000000000000000000000000000000f03f000000000000f03f".decode('hex')
#         geom = geometry_wkb(wkb)
#         self.failUnlessEqual(geom['type'], "MultiLineString")
#         self.failUnlessEqual(len(geom['coordinates']), 1)
#         self.failUnlessEqual(len(geom['coordinates'][0]), 2)
#         self.failUnlessEqual(geom['coordinates'][0], [(0.0, 0.0), (1.0, 1.0)])
#
# class MultiPolygonTest(unittest.TestCase):
#     def test_multipolygon(self):
#         # [1 x 1 box (0, 0, 1, 1)]
#         try:
#             wkb = bytes.fromhex("01060000000100000001030000000100000005000000000000000000f03f0000000000000000000000000000f03f000000000000f03f0000000000000000000000000000f03f00000000000000000000000000000000000000000000f03f0000000000000000")
#         except:
#             wkb = "01060000000100000001030000000100000005000000000000000000f03f0000000000000000000000000000f03f000000000000f03f0000000000000000000000000000f03f00000000000000000000000000000000000000000000f03f0000000000000000".decode('hex')
#         geom = geometry_wkb(wkb)
#         self.failUnlessEqual(geom['type'], "MultiPolygon")
#         self.failUnlessEqual(len(geom['coordinates']), 1)
#         self.failUnlessEqual(len(geom['coordinates'][0]), 1)
#         self.failUnlessEqual(len(geom['coordinates'][0][0]), 5)
#         x, y = zip(*geom['coordinates'][0][0])
#         self.failUnlessEqual(min(x), 0.0)
#         self.failUnlessEqual(min(y), 0.0)
#         self.failUnlessEqual(max(x), 1.0)
#         self.failUnlessEqual(max(y), 1.0)