1 |
# Copyright (c) 2002, 2003 by Intevation GmbH |
# Copyright (c) 2002, 2003, 2004 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
16 |
Maintenance of the test cases: |
Maintenance of the test cases: |
17 |
|
|
18 |
When during a development period the file format is changed with respect |
When during a development period the file format is changed with respect |
19 |
to the last released version for the first, the tests here should be |
to the last released version for the first time, the tests here should |
20 |
copied to the version specific test file. The round-trip tests which |
be copied to the version specific test file. The round-trip tests which |
21 |
save the session again and compare the XML files should not be copied |
save the session again and compare the XML files should not be copied |
22 |
over as they only make sense here to make sure th that the files checked |
over as they only make sense here to make sure th that the files checked |
23 |
here are actually ones that may have been written by the current thuban |
here are actually ones that may have been written by the current thuban |
89 |
self.session = None |
self.session = None |
90 |
|
|
91 |
|
|
92 |
dtd = "http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
dtd = "http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
93 |
thubanids = [((dtd, n), (None, "id")) for n in |
thubanids = [((dtd, n), (None, "id")) for n in |
94 |
["fileshapesource", "filetable", "jointable", |
["fileshapesource", "filetable", "jointable", |
95 |
"derivedshapesource"]] |
"derivedshapesource"]] |
162 |
props.SetLineWidth(data[CLASSES][i][GROUP_PROPS][1]) |
props.SetLineWidth(data[CLASSES][i][GROUP_PROPS][1]) |
163 |
props.SetFill( |
props.SetFill( |
164 |
parse_color(data[CLASSES][i][GROUP_PROPS][2])) |
parse_color(data[CLASSES][i][GROUP_PROPS][2])) |
165 |
|
if len(data[CLASSES][i][GROUP_PROPS]) > 3: |
166 |
|
props.SetSize(data[CLASSES][i][GROUP_PROPS][3]) |
167 |
|
|
168 |
if data[CLASSES][i][GROUP_TYPE] == "default": |
if data[CLASSES][i][GROUP_TYPE] == "default": |
169 |
g = ClassGroupDefault(props, data[CLASSES][i][GROUP_LABEL]) |
g = ClassGroupDefault(props, data[CLASSES][i][GROUP_LABEL]) |
187 |
# want to test whether the loading code handles that correctly. |
# want to test whether the loading code handles that correctly. |
188 |
file_contents = '''\ |
file_contents = '''\ |
189 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
190 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
191 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
192 |
title="Stra\xc3\x9fen & Landmarken"> |
title="Stra\xc3\x9fen & Landmarken"> |
193 |
<fileshapesource filetype="shapefile" id="D1" |
<fileshapesource filetype="shapefile" id="D1" |
194 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
279 |
|
|
280 |
file_contents = '''\ |
file_contents = '''\ |
281 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
282 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
283 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
284 |
title="Non ASCII column name test"> |
title="Non ASCII column name test"> |
285 |
<fileshapesource filetype="shapefile" id="D1" |
<fileshapesource filetype="shapefile" id="D1" |
286 |
filename="TestNonAsciiColumnName.shp"/> |
filename="TestNonAsciiColumnName.shp"/> |
356 |
|
|
357 |
file_contents = '''\ |
file_contents = '''\ |
358 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
359 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
360 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
361 |
title="single map&layer"> |
title="single map&layer"> |
362 |
<fileshapesource filetype="shapefile" id="D1" |
<fileshapesource filetype="shapefile" id="D1" |
363 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
390 |
self.check_format() |
self.check_format() |
391 |
|
|
392 |
|
|
393 |
|
class TestSymbolSize(ClassificationTest): |
394 |
|
|
395 |
|
file_contents = '''\ |
396 |
|
<?xml version="1.0" encoding="UTF-8"?> |
397 |
|
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
398 |
|
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" title="Thuban sample session"> |
399 |
|
<fileshapesource filetype="shapefile" id="D813968480" filename="../../Data/iceland/cultural_landmark-point.shp"/> |
400 |
|
<map title="Iceland map"> |
401 |
|
<layer title="cultural_landmark-point" stroke_width="1" shapestore="D813968480" visible="true" stroke="#000000" fill="#000000"> |
402 |
|
<classification field="CLPTLABEL" field_type="string"> |
403 |
|
<clnull label=""> |
404 |
|
<cldata stroke="#000000" stroke_width="1" size="3" fill="#000000"/> |
405 |
|
</clnull> |
406 |
|
<clpoint label="" value="RUINS"> |
407 |
|
<cldata stroke="#000000" stroke_width="1" size="6" fill="#ffffff"/> |
408 |
|
</clpoint> |
409 |
|
<clpoint label="" value="FARM"> |
410 |
|
<cldata stroke="#000000" stroke_width="1" size="9" fill="#ffff00"/> |
411 |
|
</clpoint> |
412 |
|
</classification> |
413 |
|
</layer> |
414 |
|
</map> |
415 |
|
</session> |
416 |
|
''' |
417 |
|
|
418 |
|
def test(self): |
419 |
|
"""Test that the size attribute for point symbols is correctly |
420 |
|
loaded for a layer.""" |
421 |
|
eq = self.assertEquals |
422 |
|
session = load_session(self.filename()) |
423 |
|
self.session = session |
424 |
|
|
425 |
|
map = session.Maps()[0] # only one map in the sample |
426 |
|
|
427 |
|
expected = [("cultural_landmark-point", 2, |
428 |
|
[("default", (), "", |
429 |
|
("#000000", 1, "#000000", 3)), |
430 |
|
("single", "RUINS", "", |
431 |
|
("#000000", 1, "#ffffff", 6)), |
432 |
|
("single", "FARM", "", |
433 |
|
("#000000", 1, "#ffff00", 9))])] |
434 |
|
|
435 |
|
self.TestLayers(map.Layers(), expected) |
436 |
|
|
437 |
|
self.check_format() |
438 |
|
|
439 |
|
|
440 |
class TestClassification(ClassificationTest): |
class TestClassification(ClassificationTest): |
441 |
|
|
442 |
file_contents = '''\ |
file_contents = '''\ |
443 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
444 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
445 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
446 |
title="single map&layer"> |
title="single map&layer"> |
447 |
<fileshapesource filetype="shapefile" id="D138389860" |
<fileshapesource filetype="shapefile" id="D138389860" |
448 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
533 |
|
|
534 |
file_contents = '''\ |
file_contents = '''\ |
535 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
536 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
537 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
538 |
title="single map&layer"> |
title="single map&layer"> |
539 |
<fileshapesource filetype="shapefile" id="D1" |
<fileshapesource filetype="shapefile" id="D1" |
540 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
581 |
|
|
582 |
file_contents = '''\ |
file_contents = '''\ |
583 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
584 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
585 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
586 |
title="single map&layer"> |
title="single map&layer"> |
587 |
<fileshapesource filetype="shapefile" id="D2" |
<fileshapesource filetype="shapefile" id="D2" |
588 |
filename="../../Data/iceland/roads-line.shp"/> |
filename="../../Data/iceland/roads-line.shp"/> |
659 |
|
|
660 |
file_contents = '''\ |
file_contents = '''\ |
661 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
662 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
663 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
664 |
title="single map&layer"> |
title="single map&layer"> |
665 |
<map title="Test Map"> |
<map title="Test Map"> |
666 |
<rasterlayer visible="false" filename="../../Data/iceland/island.tif" |
<rasterlayer visible="false" filename="../../Data/iceland/island.tif" |
693 |
class TestJoinedTable(LoadSessionTest): |
class TestJoinedTable(LoadSessionTest): |
694 |
|
|
695 |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
696 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
697 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" title="A Joined Table session"> |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" title="A Joined Table session"> |
698 |
<fileshapesource filetype="shapefile" id="D137227612" |
<fileshapesource filetype="shapefile" id="D137227612" |
699 |
filename="../../Data/iceland/roads-line.shp"/> |
filename="../../Data/iceland/roads-line.shp"/> |
700 |
<filetable filetype="DBF" filename="load_joinedtable.dbf" id="D136171140" |
<filetable filetype="DBF" filename="load_joinedtable.dbf" id="D136171140" |
744 |
# test whether they're supported correctly. |
# test whether they're supported correctly. |
745 |
|
|
746 |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
747 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
748 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" title="Thuban sample session"> |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" title="Thuban sample session"> |
749 |
<fileshapesource filetype="shapefile" id="D145265052" |
<fileshapesource filetype="shapefile" id="D145265052" |
750 |
filename="../../Data/iceland/political.shp"/> |
filename="../../Data/iceland/political.shp"/> |
751 |
<fileshapesource filetype="shapefile" id="D145412868" |
<fileshapesource filetype="shapefile" id="D145412868" |
801 |
class TestPostGISLayer(LoadSessionTest): |
class TestPostGISLayer(LoadSessionTest): |
802 |
|
|
803 |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
804 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
805 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
806 |
title="unnamed session"> |
title="unnamed session"> |
807 |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
808 |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
809 |
<dbshapesource tablename="landmarks" id="D143149420" dbconn="D142684948"/> |
<dbshapesource id="D143149420" dbconn="D142684948" |
810 |
|
tablename="landmarks_point_id" id_column="point_id" |
811 |
|
geometry_column="the_geom" /> |
812 |
<map title="unnamed map"> |
<map title="unnamed map"> |
813 |
<layer shapestore="D143149420" visible="true" stroke="#000000" |
<layer shapestore="D143149420" visible="true" stroke="#000000" |
814 |
title="landmarks" stroke_width="1" fill="None"/> |
title="landmarks" stroke_width="1" fill="None"/> |
852 |
class TestPostGISLayerPassword(LoadSessionTest): |
class TestPostGISLayerPassword(LoadSessionTest): |
853 |
|
|
854 |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
855 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
856 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
857 |
title="unnamed session"> |
title="unnamed session"> |
858 |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
<dbconnection port="%(port)s" host="%(host)s" user="%(user)s" |
859 |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
dbtype="postgis" id="D142684948" dbname="%(dbname)s"/> |
947 |
|
|
948 |
file_contents = '''\ |
file_contents = '''\ |
949 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
950 |
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
951 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" |
952 |
title="single map&layer"> |
title="single map&layer"> |
953 |
<fileshapesource id="D1" filename="../../Data/iceland/political.shp"/> |
<fileshapesource id="D1" filename="../../Data/iceland/political.shp"/> |
954 |
<map title="Test Map"> |
<map title="Test Map"> |
975 |
# LoadError really was about the missing attribute |
# LoadError really was about the missing attribute |
976 |
self.assertEquals(str(value), |
self.assertEquals(str(value), |
977 |
"Element " |
"Element " |
978 |
"(u'http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd'," |
"(u'http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd'," |
979 |
" u'fileshapesource') requires an attribute 'filetype'") |
" u'fileshapesource') requires an attribute 'filetype'") |
980 |
else: |
else: |
981 |
self.fail("Missing filetype attribute doesn't raise LoadError") |
self.fail("Missing filetype attribute doesn't raise LoadError") |