114 |
def compare_xml(self, xml1, xml2): |
def compare_xml(self, xml1, xml2): |
115 |
self.assertEquals(sax_eventlist(xml1), sax_eventlist(xml2)) |
self.assertEquals(sax_eventlist(xml1), sax_eventlist(xml2)) |
116 |
|
|
117 |
|
def test(self): |
118 |
|
"""Test ProjFile""" |
119 |
|
|
120 |
|
proj0 = Projection(["proj=tmerc", "ellps=clrk66"]) |
121 |
|
proj1 = Projection(["proj=utm", "ellps=clrk66"]) |
122 |
|
proj2 = Projection(["proj=lcc", "ellps=clrk66"]) |
123 |
|
|
124 |
|
eq = self.assertEquals |
125 |
|
|
126 |
|
# |
127 |
|
# __init__() |
128 |
|
# GetFilename() |
129 |
|
# SetFilename() |
130 |
|
# |
131 |
|
for name in ["", "hello_world"]: |
132 |
|
projFile = ProjFile(name) |
133 |
|
eq(projFile.GetFilename(), name) |
134 |
|
|
135 |
|
projFile.SetFilename("XXX") |
136 |
|
projFile.SetFilename(name) |
137 |
|
eq(projFile.GetFilename(), name) |
138 |
|
|
139 |
|
# initial number of projections should be 0 |
140 |
|
eq(len(projFile.GetProjections()), 0) |
141 |
|
|
142 |
|
# |
143 |
|
# Add() |
144 |
|
# Remove() |
145 |
|
# |
146 |
|
projFile.Add(proj0) |
147 |
|
eq(len(projFile.GetProjections()), 1) |
148 |
|
projFile.Remove(proj0) |
149 |
|
eq(len(projFile.GetProjections()), 0) |
150 |
|
|
151 |
|
# try to remove something that doesn't exist |
152 |
|
self.assertRaises(ValueError, projFile.Remove, proj0) |
153 |
|
|
154 |
|
projFile.Add(proj0) |
155 |
|
projFile.Add(proj1) |
156 |
|
projFile.Add(proj2) |
157 |
|
eq(len(projFile.GetProjections()), 3) |
158 |
|
|
159 |
|
# GetProjections() -- tests order |
160 |
|
projs = projFile.GetProjections() |
161 |
|
eq(projs[0], proj0) |
162 |
|
eq(projs[1], proj1) |
163 |
|
eq(projs[2], proj2) |
164 |
|
|
165 |
def testRead(self): |
def testRead(self): |
166 |
"""Test ReadProjFile""" |
"""Test ReadProjFile""" |
167 |
|
|
225 |
|
|
226 |
eq = self.assertEquals |
eq = self.assertEquals |
227 |
|
|
228 |
eq(pf.GetFileName(), filename) |
eq(pf.GetFilename(), filename) |
229 |
|
|
230 |
for proj, d in zip(pf.GetProjections(), data): |
for proj, d in zip(pf.GetProjections(), data): |
231 |
eq(proj.GetName(), d[0]) |
eq(proj.GetName(), d[0]) |