82 |
self.session = None |
self.session = None |
83 |
|
|
84 |
|
|
85 |
dtd = "http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" |
dtd = "http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
86 |
thubanids = [((dtd, n), (None, "id")) for n in |
thubanids = [((dtd, n), (None, "id")) for n in |
87 |
["fileshapesource", "filetable", "jointable", |
["fileshapesource", "filetable", "jointable", |
88 |
"derivedshapesource"]] |
"derivedshapesource"]] |
92 |
("jointable", "right"), |
("jointable", "right"), |
93 |
("derivedshapesource", "table"), |
("derivedshapesource", "table"), |
94 |
("derivedshapesource", "shapesource")]] |
("derivedshapesource", "shapesource")]] |
95 |
|
filenames = [((dtd, n), (None, m)) for n, m in |
96 |
|
[("fileshapesource", "filename"), |
97 |
|
("rasterlayer", "filename"), |
98 |
|
("filetable", "filename")]] |
99 |
del n, m, dtd |
del n, m, dtd |
100 |
|
|
101 |
def check_format(self): |
def check_format(self): |
106 |
filename = self.temp_file_name(self.id() + ".roundtrip.thuban") |
filename = self.temp_file_name(self.id() + ".roundtrip.thuban") |
107 |
save_session(self.session, filename) |
save_session(self.session, filename) |
108 |
el1 = sax_eventlist(filename = filename, ids = self.thubanids, |
el1 = sax_eventlist(filename = filename, ids = self.thubanids, |
109 |
idrefs = self.thubanidrefs) |
idrefs = self.thubanidrefs, |
110 |
|
filenames = self.filenames) |
111 |
el2 = sax_eventlist(filename = self.filename(), ids = self.thubanids, |
el2 = sax_eventlist(filename = self.filename(), ids = self.thubanids, |
112 |
idrefs = self.thubanidrefs) |
idrefs = self.thubanidrefs, |
113 |
|
filenames = self.filenames) |
114 |
if 0: |
if 0: |
115 |
for a, b in zip(el1, el2): |
for a, b in zip(el1, el2): |
116 |
print a != b and "***************" or "" |
print a != b and "***************" or "" |
176 |
file_contents = '''\ |
file_contents = '''\ |
177 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
178 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
179 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
180 |
title="single map&layer"> |
title="single map&layer"> |
181 |
<fileshapesource filetype="shapefile" id="D1" |
<fileshapesource filetype="shapefile" id="D1" |
182 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
237 |
file_contents = '''\ |
file_contents = '''\ |
238 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
239 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
240 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
241 |
title="single map&layer"> |
title="single map&layer"> |
242 |
<fileshapesource filetype="shapefile" id="D1" |
<fileshapesource filetype="shapefile" id="D1" |
243 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
362 |
file_contents = '''\ |
file_contents = '''\ |
363 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
364 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
365 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
366 |
title="single map&layer"> |
title="single map&layer"> |
367 |
<fileshapesource filetype="shapefile" id="D1" |
<fileshapesource filetype="shapefile" id="D1" |
368 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
410 |
file_contents = '''\ |
file_contents = '''\ |
411 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
412 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
413 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
414 |
title="single map&layer"> |
title="single map&layer"> |
415 |
<fileshapesource filetype="shapefile" id="D2" |
<fileshapesource filetype="shapefile" id="D2" |
416 |
filename="../../Data/iceland/roads-line.shp"/> |
filename="../../Data/iceland/roads-line.shp"/> |
442 |
title="My Layer" stroke_width="1" fill="None"> |
title="My Layer" stroke_width="1" fill="None"> |
443 |
<projection name="Unknown"> |
<projection name="Unknown"> |
444 |
<parameter value="proj=lcc"/> |
<parameter value="proj=lcc"/> |
445 |
|
<parameter value="lat_1=10"/> |
446 |
|
<parameter value="lat_2=20"/> |
447 |
<parameter value="ellps=clrk66"/> |
<parameter value="ellps=clrk66"/> |
448 |
</projection> |
</projection> |
449 |
</layer> |
</layer> |
476 |
neq(proj, None) |
neq(proj, None) |
477 |
eq(proj.GetName(), "Unknown") |
eq(proj.GetName(), "Unknown") |
478 |
eq(proj.GetParameter("proj"), "lcc") |
eq(proj.GetParameter("proj"), "lcc") |
479 |
|
eq(proj.GetParameter("lat_1"), "10") |
480 |
|
eq(proj.GetParameter("lat_2"), "20") |
481 |
eq(proj.GetParameter("ellps"), "clrk66") |
eq(proj.GetParameter("ellps"), "clrk66") |
482 |
|
|
483 |
self.check_format() |
self.check_format() |
488 |
file_contents = '''\ |
file_contents = '''\ |
489 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
490 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
491 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
492 |
title="single map&layer"> |
title="single map&layer"> |
493 |
<map title="Test Map"> |
<map title="Test Map"> |
494 |
<rasterlayer visible="false" filename="../../Data/iceland/island.tif" |
<rasterlayer visible="false" filename="../../Data/iceland/island.tif" |
522 |
|
|
523 |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
524 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
525 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" title="A Joined Table session"> |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" title="A Joined Table session"> |
526 |
<fileshapesource filetype="shapefile" id="D137227612" |
<fileshapesource filetype="shapefile" id="D137227612" |
527 |
filename="../../Data/iceland/roads-line.shp"/> |
filename="../../Data/iceland/roads-line.shp"/> |
528 |
<filetable filetype="DBF" filename="load_joinedtable.dbf" id="D136171140" |
<filetable filetype="DBF" filename="load_joinedtable.dbf" id="D136171140" |
571 |
|
|
572 |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
573 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
574 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
575 |
title="unnamed session"> |
title="unnamed session"> |
576 |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
577 |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
620 |
|
|
621 |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
622 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
623 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
624 |
title="unnamed session"> |
title="unnamed session"> |
625 |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
626 |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
715 |
file_contents = '''\ |
file_contents = '''\ |
716 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
717 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
718 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
719 |
title="single map&layer"> |
title="single map&layer"> |
720 |
<fileshapesource id="D1" filename="../../Data/iceland/political.shp"/> |
<fileshapesource id="D1" filename="../../Data/iceland/political.shp"/> |
721 |
<map title="Test Map"> |
<map title="Test Map"> |
742 |
# LoadError really was about the missing attribute |
# LoadError really was about the missing attribute |
743 |
self.assertEquals(str(value), |
self.assertEquals(str(value), |
744 |
"Element " |
"Element " |
745 |
"(u'http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd'," |
"(u'http://thuban.intevation.org/dtds/thuban-0.9.dtd'," |
746 |
" u'fileshapesource') requires an attribute 'filetype'") |
" u'fileshapesource') requires an attribute 'filetype'") |
747 |
else: |
else: |
748 |
self.fail("Missing filetype attribute doesn't raise LoadError") |
self.fail("Missing filetype attribute doesn't raise LoadError") |
749 |
|
|
750 |
if __name__ == "__main__": |
if __name__ == "__main__": |
751 |
unittest.main() |
support.run_tests() |