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-1.0.0.dtd" |
dtd = "http://thuban.intevation.org/dtds/thuban-1.1-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-1.0.dtd">\n' |
'<!DOCTYPE session SYSTEM "thuban-1.1.dtd">\n' |
115 |
'<session title="empty session" ' |
'<session title="empty session" ' |
116 |
'xmlns="http://thuban.intevation.org/dtds/thuban-1.0.0.dtd">' |
'xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd">' |
117 |
'\n</session>\n') |
'\n</session>\n') |
118 |
|
|
119 |
self.validate_data(written_contents) |
self.validate_data(written_contents) |
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-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
145 |
<session title="single map&layer" |
<session title="single map&layer" |
146 |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0.0.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd"> |
147 |
<fileshapesource id="D1" |
<fileshapesource id="D1" |
148 |
filename="../../Data/iceland/political.shp" |
filename="../../Data/iceland/political.shp" |
149 |
filetype="shapefile"/> |
filetype="shapefile"/> |
203 |
written_contents = file.read() |
written_contents = file.read() |
204 |
file.close() |
file.close() |
205 |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
206 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
207 |
<session title="single map&layer" |
<session title="single map&layer" |
208 |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0.0.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd"> |
209 |
<fileshapesource id="D1" |
<fileshapesource id="D1" |
210 |
filename="../../Data/iceland/political.shp" |
filename="../../Data/iceland/political.shp" |
211 |
filetype="shapefile"/> |
filetype="shapefile"/> |
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-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
256 |
<session title="single map&layer" |
<session title="single map&layer" |
257 |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0.0.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd"> |
258 |
<map title="Test Map"> |
<map title="Test Map"> |
259 |
<rasterlayer title="My RasterLayer" |
<rasterlayer title="My RasterLayer" |
260 |
filename="../../Data/iceland/island.tif" |
filename="../../Data/iceland/island.tif" |
319 |
written_contents = file.read() |
written_contents = file.read() |
320 |
file.close() |
file.close() |
321 |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
322 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
323 |
<session title="Map with Classifications" |
<session title="Map with Classifications" |
324 |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0.0.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd"> |
325 |
<fileshapesource id="D1" |
<fileshapesource id="D1" |
326 |
filename="../../Data/iceland/political.shp" |
filename="../../Data/iceland/political.shp" |
327 |
filetype="shapefile"/> |
filetype="shapefile"/> |
390 |
written_contents = file.read() |
written_contents = file.read() |
391 |
file.close() |
file.close() |
392 |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
393 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
394 |
<session title="a DBF Table session" |
<session title="a DBF Table session" |
395 |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0.0.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd"> |
396 |
<filetable id="D1" filename="../../Data/iceland/political.dbf" |
<filetable id="D1" filename="../../Data/iceland/political.dbf" |
397 |
filetype="DBF" title="political"/> |
filetype="DBF" title="political"/> |
398 |
</session>''' |
</session>''' |
448 |
written_contents = file.read() |
written_contents = file.read() |
449 |
file.close() |
file.close() |
450 |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
451 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
452 |
<session title="A Joined Table session" |
<session title="A Joined Table session" |
453 |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0.0.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd"> |
454 |
<fileshapesource filename="../../Data/iceland/roads-line.shp" |
<fileshapesource filename="../../Data/iceland/roads-line.shp" |
455 |
filetype="shapefile" id="D142197204"/> |
filetype="shapefile" id="D142197204"/> |
456 |
<filetable filename="save_joinedtable.dbf" |
<filetable filename="save_joinedtable.dbf" |
491 |
def _fetch_table_information(self): |
def _fetch_table_information(self): |
492 |
# pretend that we've found a geometry column |
# pretend that we've found a geometry column |
493 |
self.geometry_column = "the_geom" |
self.geometry_column = "the_geom" |
494 |
|
def IDColumn(self): |
495 |
|
"""Return an object with a name attribute with value 'gid'""" |
496 |
|
class dummycol: |
497 |
|
name = "gid" |
498 |
|
return dummycol |
499 |
|
|
500 |
session = Session("A PostGIS Session") |
session = Session("A PostGIS Session") |
501 |
try: |
try: |
518 |
written = file.read() |
written = file.read() |
519 |
file.close() |
file.close() |
520 |
expected = '''<?xml version="1.0" encoding="UTF-8"?> |
expected = '''<?xml version="1.0" encoding="UTF-8"?> |
521 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
522 |
<session title="A PostGIS Session" |
<session title="A PostGIS Session" |
523 |
xmlns="http://thuban.intevation.org/dtds/thuban-1.0.0.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd"> |
524 |
<dbconnection id="DB" |
<dbconnection id="DB" |
525 |
dbtype="postgis" dbname="plugh" |
dbtype="postgis" dbname="plugh" |
526 |
host="xyzzy" port="42" |
host="xyzzy" port="42" |
527 |
user="grue"/> |
user="grue"/> |
528 |
<dbshapesource id="roads" dbconn="DB" tablename="roads"/> |
<dbshapesource id="roads" dbconn="DB" tablename="roads" |
529 |
|
id_column="gid" geometry_column="the_geom"/> |
530 |
<map title="Test Map"> |
<map title="Test Map"> |
531 |
<layer title="Roads to Nowhere" |
<layer title="Roads to Nowhere" |
532 |
shapestore="roads" visible="true" |
shapestore="roads" visible="true" |