82 |
self.session = None |
self.session = None |
83 |
|
|
84 |
|
|
85 |
dtd = "http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
dtd = "http://thuban.intevation.org/dtds/thuban-1.0-dev.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"]] |
173 |
|
|
174 |
class TestSingleLayer(LoadSessionTest): |
class TestSingleLayer(LoadSessionTest): |
175 |
|
|
176 |
|
# Note: The use of & and non-ascii characters is deliberate. We |
177 |
|
# want to test whether the loading code handles that correctly. |
178 |
file_contents = '''\ |
file_contents = '''\ |
179 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
180 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
181 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd" |
182 |
title="single map&layer"> |
title="single map&layer"> |
183 |
<fileshapesource filetype="shapefile" id="D1" |
<fileshapesource filetype="shapefile" id="D1" |
184 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
185 |
<map title="Test Map"> |
<map title="Test Map"> |
186 |
<projection name="Unknown"> |
<projection epsg="32627" name="WGS 84 / UTM zone 27N"> |
187 |
<parameter value="zone=26"/> |
<parameter value="datum=WGS84"/> |
188 |
|
<parameter value="ellps=WGS84"/> |
189 |
<parameter value="proj=utm"/> |
<parameter value="proj=utm"/> |
190 |
<parameter value="ellps=clrk66"/> |
<parameter value="units=m"/> |
191 |
|
<parameter value="zone=27"/> |
192 |
</projection> |
</projection> |
193 |
<layer shapestore="D1" visible="true" |
<layer shapestore="D1" visible="true" |
194 |
stroke="#000000" title="My Layer" stroke_width="1" |
stroke="#000000" title="My Layer" stroke_width="1" |
213 |
# Check the map's attributes |
# Check the map's attributes |
214 |
map = maps[0] |
map = maps[0] |
215 |
eq(map.Title(), "Test Map") |
eq(map.Title(), "Test Map") |
216 |
|
proj = map.GetProjection() |
217 |
|
eq(proj.GetName(), "WGS 84 / UTM zone 27N") |
218 |
|
eq(proj.EPSGCode(), "32627") |
219 |
|
params = proj.GetAllParameters() |
220 |
|
params.sort() |
221 |
|
eq(params, ["datum=WGS84", "ellps=WGS84", "proj=utm", "units=m", |
222 |
|
"zone=27"]) |
223 |
|
|
224 |
# the map has a single layer |
# the map has a single layer |
225 |
layers = map.Layers() |
layers = map.Layers() |
247 |
|
|
248 |
file_contents = '''\ |
file_contents = '''\ |
249 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
250 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
251 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd" |
252 |
title="single map&layer"> |
title="single map&layer"> |
253 |
<fileshapesource filetype="shapefile" id="D1" |
<fileshapesource filetype="shapefile" id="D1" |
254 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
372 |
|
|
373 |
file_contents = '''\ |
file_contents = '''\ |
374 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
375 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
376 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd" |
377 |
title="single map&layer"> |
title="single map&layer"> |
378 |
<fileshapesource filetype="shapefile" id="D1" |
<fileshapesource filetype="shapefile" id="D1" |
379 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
420 |
|
|
421 |
file_contents = '''\ |
file_contents = '''\ |
422 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
423 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
424 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd" |
425 |
title="single map&layer"> |
title="single map&layer"> |
426 |
<fileshapesource filetype="shapefile" id="D2" |
<fileshapesource filetype="shapefile" id="D2" |
427 |
filename="../../Data/iceland/roads-line.shp"/> |
filename="../../Data/iceland/roads-line.shp"/> |
498 |
|
|
499 |
file_contents = '''\ |
file_contents = '''\ |
500 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
501 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
502 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd" |
503 |
title="single map&layer"> |
title="single map&layer"> |
504 |
<map title="Test Map"> |
<map title="Test Map"> |
505 |
<rasterlayer visible="false" filename="../../Data/iceland/island.tif" |
<rasterlayer visible="false" filename="../../Data/iceland/island.tif" |
532 |
class TestJoinedTable(LoadSessionTest): |
class TestJoinedTable(LoadSessionTest): |
533 |
|
|
534 |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
535 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
536 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" title="A Joined Table session"> |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd" title="A Joined Table session"> |
537 |
<fileshapesource filetype="shapefile" id="D137227612" |
<fileshapesource filetype="shapefile" id="D137227612" |
538 |
filename="../../Data/iceland/roads-line.shp"/> |
filename="../../Data/iceland/roads-line.shp"/> |
539 |
<filetable filetype="DBF" filename="load_joinedtable.dbf" id="D136171140" |
<filetable filetype="DBF" filename="load_joinedtable.dbf" id="D136171140" |
581 |
class TestPostGISLayer(LoadSessionTest): |
class TestPostGISLayer(LoadSessionTest): |
582 |
|
|
583 |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
584 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
585 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd" |
586 |
title="unnamed session"> |
title="unnamed session"> |
587 |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
588 |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
630 |
class TestPostGISLayerPassword(LoadSessionTest): |
class TestPostGISLayerPassword(LoadSessionTest): |
631 |
|
|
632 |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
633 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
634 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd" |
635 |
title="unnamed session"> |
title="unnamed session"> |
636 |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
637 |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
725 |
|
|
726 |
file_contents = '''\ |
file_contents = '''\ |
727 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
728 |
<!DOCTYPE session SYSTEM "thuban-0.9.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
729 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd" |
730 |
title="single map&layer"> |
title="single map&layer"> |
731 |
<fileshapesource id="D1" filename="../../Data/iceland/political.shp"/> |
<fileshapesource id="D1" filename="../../Data/iceland/political.shp"/> |
732 |
<map title="Test Map"> |
<map title="Test Map"> |
753 |
# LoadError really was about the missing attribute |
# LoadError really was about the missing attribute |
754 |
self.assertEquals(str(value), |
self.assertEquals(str(value), |
755 |
"Element " |
"Element " |
756 |
"(u'http://thuban.intevation.org/dtds/thuban-0.9.dtd'," |
"(u'http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd'," |
757 |
" u'fileshapesource') requires an attribute 'filetype'") |
" u'fileshapesource') requires an attribute 'filetype'") |
758 |
else: |
else: |
759 |
self.fail("Missing filetype attribute doesn't raise LoadError") |
self.fail("Missing filetype attribute doesn't raise LoadError") |