17 |
|
|
18 |
When during a development period the file format is changed with respect |
When during a development period the file format is changed with respect |
19 |
to the last released version for the first, the tests here should be |
to the last released version for the first, the tests here should be |
20 |
copied to the version specific test file. |
copied to the version specific test file. The round-trip tests which |
21 |
|
save the session again and compare the XML files should not be copied |
22 |
|
over as they only make sense here to make sure th that the files checked |
23 |
|
here are actually ones that may have been written by the current thuban |
24 |
|
version. |
25 |
""" |
""" |
26 |
|
|
27 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
34 |
import support |
import support |
35 |
support.initthuban() |
support.initthuban() |
36 |
|
|
37 |
|
from xmlsupport import sax_eventlist |
38 |
|
from Thuban.Model.save import save_session |
39 |
from Thuban.Model.load import load_session, parse_color |
from Thuban.Model.load import load_session, parse_color |
40 |
from Thuban.Model.color import Color |
from Thuban.Model.color import Color |
41 |
from Thuban.Model.classification import ClassGroupProperties, ClassGroupRange,\ |
from Thuban.Model.classification import ClassGroupProperties, ClassGroupRange,\ |
76 |
self.session.Destroy() |
self.session.Destroy() |
77 |
self.session = None |
self.session = None |
78 |
|
|
79 |
|
def check_format(self): |
80 |
|
"""Check whether the file we loaded from matches the one that |
81 |
|
would be written. Call this from each test case after loading |
82 |
|
the session |
83 |
|
""" |
84 |
|
filename = self.temp_file_name(self.id() + ".roundtrip.thuban") |
85 |
|
save_session(self.session, filename) |
86 |
|
el1 = sax_eventlist(filename = filename) |
87 |
|
el2 = sax_eventlist(filename = self.filename()) |
88 |
|
self.assertEquals(el1, el2) |
89 |
|
|
90 |
|
|
91 |
class ClassificationTest(LoadSessionTest): |
class ClassificationTest(LoadSessionTest): |
92 |
|
|
146 |
<!DOCTYPE session SYSTEM "thuban.dtd"> |
<!DOCTYPE session SYSTEM "thuban.dtd"> |
147 |
<session title="single map&layer"> |
<session title="single map&layer"> |
148 |
<map title="Test Map"> |
<map title="Test Map"> |
149 |
<projection> |
<projection name="Unknown"> |
150 |
<parameter value="zone=26"/> |
<parameter value="zone=26"/> |
151 |
<parameter value="proj=utm"/> |
<parameter value="proj=utm"/> |
152 |
<parameter value="ellps=clrk66"/> |
<parameter value="ellps=clrk66"/> |
153 |
</projection> |
</projection> |
154 |
<layer title="My Layer" stroke_width="1" fill="None" |
<layer title="My Layer" stroke_width="1" fill="None" |
155 |
filename="../../Data/iceland/political.shp" |
filename="../../Data/iceland/political.shp" |
156 |
stroke="#000000"/> |
stroke="#000000" visible="true"/> |
157 |
</map> |
</map> |
158 |
</session> |
</session> |
159 |
''' |
''' |
191 |
eq(layer.GetClassification().GetDefaultLineColor().hex(), "#000000") |
eq(layer.GetClassification().GetDefaultLineColor().hex(), "#000000") |
192 |
eq(layer.Visible(), True) |
eq(layer.Visible(), True) |
193 |
|
|
194 |
|
self.check_format() |
195 |
|
|
196 |
self.session.Destroy() |
self.session.Destroy() |
197 |
self.session = None |
self.session = None |
198 |
|
|
204 |
<!DOCTYPE session SYSTEM "thuban.dtd"> |
<!DOCTYPE session SYSTEM "thuban.dtd"> |
205 |
<session title="single map&layer"> |
<session title="single map&layer"> |
206 |
<map title="Test Map"> |
<map title="Test Map"> |
207 |
<projection> |
<projection name="Unknown"> |
208 |
<parameter value="zone=26"/> |
<parameter value="zone=26"/> |
209 |
<parameter value="proj=utm"/> |
<parameter value="proj=utm"/> |
210 |
<parameter value="ellps=clrk66"/> |
<parameter value="ellps=clrk66"/> |
231 |
|
|
232 |
eq(layer.Visible(), False) |
eq(layer.Visible(), False) |
233 |
|
|
234 |
|
self.check_format() |
235 |
|
|
236 |
|
|
237 |
class TestClassification(ClassificationTest): |
class TestClassification(ClassificationTest): |
322 |
<!DOCTYPE session SYSTEM "thuban.dtd"> |
<!DOCTYPE session SYSTEM "thuban.dtd"> |
323 |
<session title="single map&layer"> |
<session title="single map&layer"> |
324 |
<map title="Test Map"> |
<map title="Test Map"> |
325 |
<projection> |
<projection name="Unknown"> |
326 |
<parameter value="zone=26"/> |
<parameter value="zone=26"/> |
327 |
<parameter value="proj=utm"/> |
<parameter value="proj=utm"/> |
328 |
<parameter value="ellps=clrk66"/> |
<parameter value="ellps=clrk66"/> |
329 |
</projection> |
</projection> |
330 |
<layer title="My Layer" stroke_width="1" fill="None" |
<layer title="My Layer" stroke_width="1" fill="None" |
331 |
filename="../../Data/iceland/political.shp" |
filename="../../Data/iceland/political.shp" |
332 |
stroke="#000000"> |
stroke="#000000" visible="true"> |
333 |
<classification field="POPYREG" field_type="string"> |
<classification field="POPYREG" field_type="string"> |
334 |
<clnull label="hallo"> |
<clnull label="hallo"> |
335 |
<cldata stroke="#000000" stroke_width="1" fill="None"/> |
<cldata stroke="#000000" stroke_width="1" fill="None"/> |
358 |
("#000000", 2, "None"))])] |
("#000000", 2, "None"))])] |
359 |
|
|
360 |
self.TestLayers(map.Layers(), expected) |
self.TestLayers(map.Layers(), expected) |
361 |
|
self.check_format() |
362 |
|
|
363 |
|
|
364 |
class TestLayerProjection(LoadSessionTest): |
class TestLayerProjection(LoadSessionTest): |
368 |
<!DOCTYPE session SYSTEM "thuban.dtd"> |
<!DOCTYPE session SYSTEM "thuban.dtd"> |
369 |
<session title="single map&layer"> |
<session title="single map&layer"> |
370 |
<map title="Test Map"> |
<map title="Test Map"> |
371 |
<projection> |
<projection name="Unknown"> |
372 |
<parameter value="zone=26"/> |
<parameter value="zone=26"/> |
373 |
<parameter value="proj=utm"/> |
<parameter value="proj=utm"/> |
374 |
<parameter value="ellps=clrk66"/> |
<parameter value="ellps=clrk66"/> |
375 |
</projection> |
</projection> |
376 |
<layer title="My Layer" stroke_width="1" fill="None" |
<layer title="My Layer" stroke_width="1" fill="None" |
377 |
filename="../../Data/iceland/political.shp" |
filename="../../Data/iceland/political.shp" |
378 |
stroke="#000000"> |
stroke="#000000" visible="true"> |
379 |
<projection name="hello"> |
<projection name="hello"> |
380 |
<parameter value="zone=13"/> |
<parameter value="zone=13"/> |
381 |
<parameter value="proj=tmerc"/> |
<parameter value="proj=tmerc"/> |
392 |
</layer> |
</layer> |
393 |
<layer title="My Layer" stroke_width="1" fill="None" |
<layer title="My Layer" stroke_width="1" fill="None" |
394 |
filename="../../Data/iceland/political.shp" |
filename="../../Data/iceland/political.shp" |
395 |
stroke="#000000"> |
stroke="#000000" visible="true"> |
396 |
<projection> |
<projection name="Unknown"> |
397 |
<parameter value="proj=lcc"/> |
<parameter value="proj=lcc"/> |
398 |
<parameter value="ellps=clrk66"/> |
<parameter value="ellps=clrk66"/> |
399 |
</projection> |
</projection> |
429 |
eq(proj.GetParameter("proj"), "lcc") |
eq(proj.GetParameter("proj"), "lcc") |
430 |
eq(proj.GetParameter("ellps"), "clrk66") |
eq(proj.GetParameter("ellps"), "clrk66") |
431 |
|
|
432 |
|
self.check_format() |
433 |
|
|
434 |
|
|
435 |
class TestRasterLayer(LoadSessionTest): |
class TestRasterLayer(LoadSessionTest): |
436 |
|
|
465 |
os.pardir, os.pardir, |
os.pardir, os.pardir, |
466 |
"Data", "iceland", |
"Data", "iceland", |
467 |
"island.tif"))) |
"island.tif"))) |
468 |
|
self.check_format() |
469 |
|
|
470 |
if __name__ == "__main__": |
if __name__ == "__main__": |
471 |
unittest.main() |
unittest.main() |