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-dev.dtd" |
dtd = "http://thuban.intevation.org/dtds/thuban-0.9.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"]] |
78 |
("dbshapesource", "dbconn")]] |
("dbshapesource", "dbconn")]] |
79 |
del n, m, dtd |
del n, m, dtd |
80 |
|
|
81 |
|
def tearDown(self): |
82 |
|
"""Call self.session.Destroy |
83 |
|
|
84 |
|
Test cases that create session should bind it to self.session so |
85 |
|
that it gets destroyed properly |
86 |
|
""" |
87 |
|
if hasattr(self, "session"): |
88 |
|
self.session.Destroy() |
89 |
|
self.session = None |
90 |
|
|
91 |
def compare_xml(self, xml1, xml2): |
def compare_xml(self, xml1, xml2): |
92 |
list1 = xmlsupport.sax_eventlist(xml1, ids = self.thubanids, |
list1 = xmlsupport.sax_eventlist(xml1, ids = self.thubanids, |
93 |
idrefs = self.thubanidrefs) |
idrefs = self.thubanidrefs) |
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-0.9.dtd">\n' |
115 |
'<session title="empty session" ' |
'<session title="empty session" ' |
116 |
'xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">' |
'xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd">' |
117 |
'\n</session>\n') |
'\n</session>\n') |
118 |
|
|
119 |
self.validate_data(written_contents) |
self.validate_data(written_contents) |
140 |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
141 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
142 |
<session title="single map&layer" |
<session title="single map&layer" |
143 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
144 |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
145 |
<map title="Test Map"> |
<map title="Test Map"> |
146 |
<projection name="Unknown"> |
<projection name="Unknown"> |
200 |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
201 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
202 |
<session title="single map&layer" |
<session title="single map&layer" |
203 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
204 |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
205 |
<map title="Test Map"> |
<map title="Test Map"> |
206 |
<projection name="Unknown"> |
<projection name="Unknown"> |
246 |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
247 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
248 |
<session title="single map&layer" |
<session title="single map&layer" |
249 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
250 |
<map title="Test Map"> |
<map title="Test Map"> |
251 |
<rasterlayer title="My RasterLayer" filename="%s" |
<rasterlayer title="My RasterLayer" filename="%s" |
252 |
visible="true"> |
visible="true"> |
313 |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
314 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
315 |
<session title="Map with Classifications" |
<session title="Map with Classifications" |
316 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
317 |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
<fileshapesource id="D1" filename="%s" filetype="shapefile"/> |
318 |
<map title="Test Map"> |
<map title="Test Map"> |
319 |
<projection name="Unknown"> |
<projection name="Unknown"> |
371 |
|
|
372 |
def test_dbf_table(self): |
def test_dbf_table(self): |
373 |
"""Test saving a session with a dbf table link""" |
"""Test saving a session with a dbf table link""" |
374 |
session = Session("a DBF Table session") |
session = self.session = Session("a DBF Table session") |
375 |
# use shapefile from the example data |
# use shapefile from the example data |
376 |
dbffile = os.path.join(os.path.dirname(__file__), |
dbffile = os.path.join(os.path.dirname(__file__), |
377 |
os.pardir, "Data", "iceland", "political.dbf") |
os.pardir, "Data", "iceland", "political.dbf") |
386 |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
387 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
388 |
<session title="a DBF Table session" |
<session title="a DBF Table session" |
389 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
390 |
<filetable id="D1" filename="%s" filetype="DBF" title="political"/> |
<filetable id="D1" filename="%s" filetype="DBF" title="political"/> |
391 |
</session>''' |
</session>''' |
392 |
|
|
446 |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
expected_template = '''<?xml version="1.0" encoding="UTF-8"?> |
447 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
448 |
<session title="A Joined Table session" |
<session title="A Joined Table session" |
449 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
450 |
<fileshapesource filename="%(shpfile)s" |
<fileshapesource filename="%(shpfile)s" |
451 |
filetype="shapefile" id="D142197204"/> |
filetype="shapefile" id="D142197204"/> |
452 |
<filetable filename="%(dbffile)s" |
<filetable filename="%(dbffile)s" |
514 |
expected = '''<?xml version="1.0" encoding="UTF-8"?> |
expected = '''<?xml version="1.0" encoding="UTF-8"?> |
515 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
516 |
<session title="A PostGIS Session" |
<session title="A PostGIS Session" |
517 |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"> |
xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"> |
518 |
<dbconnection id="DB" |
<dbconnection id="DB" |
519 |
dbtype="postgis" dbname="plugh" |
dbtype="postgis" dbname="plugh" |
520 |
host="xyzzy" port="42" |
host="xyzzy" port="42" |