65 |
class SaveSessionTest(unittest.TestCase, support.FileTestMixin, |
class SaveSessionTest(unittest.TestCase, support.FileTestMixin, |
66 |
xmlsupport.ValidationTest): |
xmlsupport.ValidationTest): |
67 |
|
|
68 |
dtd = "http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
dtd = "http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd" |
69 |
thubanids = [((dtd, n), (None, "id")) for n in |
thubanids = [((dtd, n), (None, "id")) for n in |
70 |
["fileshapesource", "filetable", "jointable", |
["fileshapesource", "filetable", "jointable", |
71 |
"derivedshapesource", "dbshapesource", "dbconnection"]] |
"derivedshapesource", "dbshapesource", "dbconnection"]] |
111 |
file.close() |
file.close() |
112 |
self.compare_xml(written_contents, |
self.compare_xml(written_contents, |
113 |
'<?xml version="1.0" encoding="UTF-8"?>\n' |
'<?xml version="1.0" encoding="UTF-8"?>\n' |
114 |
'<!DOCTYPE session SYSTEM "thuban-0.9.dtd">\n' |
'<!DOCTYPE session SYSTEM "thuban-1.0.dtd">\n' |
115 |
'<session title="empty session" ' |
'<session title="empty session" ' |
116 |
'xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd">' |
'xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd">' |
117 |
'\n</session>\n') |
'\n</session>\n') |
118 |
|
|
119 |
self.validate_data(written_contents) |
self.validate_data(written_contents) |
122 |
"""Save a session with a single map with a single layer""" |
"""Save a session with a single map with a single layer""" |
123 |
# deliberately put an apersand in the title :) |
# deliberately put an apersand in the title :) |
124 |
session = Session("single map&layer") |
session = Session("single map&layer") |
125 |
proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"]) |
proj = Projection(["proj=utm", "zone=27", "ellps=WGS84", |
126 |
|
"datum=WGS84", "units=m"], |
127 |
|
name = "WGS 84 / UTM zone 27N", |
128 |
|
epsg = "32627") |
129 |
map = Map("Test Map", projection = proj) |
map = Map("Test Map", projection = proj) |
130 |
session.AddMap(map) |
session.AddMap(map) |
131 |
# use shapefile from the example data |
# use shapefile from the example data |
141 |
written_contents = file.read() |
written_contents = file.read() |
142 |
file.close() |
file.close() |
143 |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
144 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
145 |
<session title="single map&layer" |
<session title="single map&layer" |
146 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"> |
147 |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
148 |
<map title="Test Map"> |
<map title="Test Map"> |
149 |
<projection name="Unknown"> |
<projection epsg="32627" name="WGS 84 / UTM zone 27N"> |
|
<parameter value="zone=26"/> |
|
150 |
<parameter value="proj=utm"/> |
<parameter value="proj=utm"/> |
151 |
<parameter value="ellps=clrk66"/> |
<parameter value="zone=27"/> |
152 |
|
<parameter value="ellps=WGS84"/> |
153 |
|
<parameter value="datum=WGS84"/> |
154 |
|
<parameter value="units=m"/> |
155 |
</projection> |
</projection> |
156 |
<layer title="My Layer" shapestore="D1" |
<layer title="My Layer" shapestore="D1" |
157 |
fill="None" stroke="#000000" stroke_width="1" visible="%s"/> |
fill="None" stroke="#000000" stroke_width="1" visible="%s"/> |
204 |
written_contents = file.read() |
written_contents = file.read() |
205 |
file.close() |
file.close() |
206 |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
207 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
208 |
<session title="single map&layer" |
<session title="single map&layer" |
209 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"> |
210 |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
211 |
<map title="Test Map"> |
<map title="Test Map"> |
212 |
<projection name="Unknown"> |
<projection name="Unknown"> |
252 |
written_contents = file.read() |
written_contents = file.read() |
253 |
file.close() |
file.close() |
254 |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
255 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
256 |
<session title="single map&layer" |
<session title="single map&layer" |
257 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"> |
258 |
<map title="Test Map"> |
<map title="Test Map"> |
259 |
<rasterlayer title="My RasterLayer" filename="%s" |
<rasterlayer title="My RasterLayer" filename="%s" |
260 |
visible="true"> |
visible="true"> |
319 |
written_contents = file.read() |
written_contents = file.read() |
320 |
file.close() |
file.close() |
321 |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
322 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
323 |
<session title="Map with Classifications" |
<session title="Map with Classifications" |
324 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"> |
325 |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
326 |
<map title="Test Map"> |
<map title="Test Map"> |
327 |
<projection name="Unknown"> |
<projection name="Unknown"> |
392 |
written_contents = file.read() |
written_contents = file.read() |
393 |
file.close() |
file.close() |
394 |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
395 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
396 |
<session title="a DBF Table session" |
<session title="a DBF Table session" |
397 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"> |
398 |
<filetable id="D1" filename="%s" filetype="DBF" title="political"/> |
<filetable id="D1" filename="%s" filetype="DBF" title="political"/> |
399 |
</session>''' |
</session>''' |
400 |
|
|
452 |
written_contents = file.read() |
written_contents = file.read() |
453 |
file.close() |
file.close() |
454 |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
455 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
456 |
<session title="A Joined Table session" |
<session title="A Joined Table session" |
457 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"> |
458 |
<fileshapesource filename="%(shpfile)s" |
<fileshapesource filename="%(shpfile)s" |
459 |
filetype="shapefile" id="D142197204"/> |
filetype="shapefile" id="D142197204"/> |
460 |
<filetable filename="%(dbffile)s" |
<filetable filename="%(dbffile)s" |
520 |
written = file.read() |
written = file.read() |
521 |
file.close() |
file.close() |
522 |
expected = '''<?xml version="1.0" encoding="UTF-8"?> |
expected = '''<?xml version="1.0" encoding="UTF-8"?> |
523 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
524 |
<session title="A PostGIS Session" |
<session title="A PostGIS Session" |
525 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"> |
526 |
<dbconnection id="DB" |
<dbconnection id="DB" |
527 |
dbtype="postgis" dbname="plugh" |
dbtype="postgis" dbname="plugh" |
528 |
host="xyzzy" port="42" |
host="xyzzy" port="42" |