53 |
from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \ |
from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \ |
54 |
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BASELINE |
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BASELINE |
55 |
|
|
|
|
|
56 |
def filenames_equal(name1, name2): |
def filenames_equal(name1, name2): |
57 |
"""Return true if the filenames name1 and name2 are equal. |
"""Return true if the filenames name1 and name2 are equal. |
58 |
|
|
123 |
print a != b and "***************" or "" |
print a != b and "***************" or "" |
124 |
print a |
print a |
125 |
print b |
print b |
126 |
|
|
127 |
self.assertEquals(el1, el2, |
self.assertEquals(el1, el2, |
128 |
"loaded file not equivalent to the saved file") |
"loaded file not equivalent to the saved file") |
129 |
|
|
663 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.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" use_mask="true" filename="../../Data/iceland/island.tif" |
667 |
title="My RasterLayer"/> |
title="My RasterLayer"/> |
668 |
</map> |
</map> |
669 |
</session> |
</session> |
680 |
|
|
681 |
layer = map.Layers()[0] # one layer in the sample |
layer = map.Layers()[0] # one layer in the sample |
682 |
|
|
683 |
|
layer.SetUseMask(True) |
684 |
|
|
685 |
eq(layer.Title(), "My RasterLayer") |
eq(layer.Title(), "My RasterLayer") |
686 |
self.failIf(layer.Visible()) |
self.failIf(layer.Visible()) |
687 |
self.failUnless(filenames_equal(layer.GetImageFilename(), |
self.failUnless(filenames_equal(layer.GetImageFilename(), |
1018 |
file_contents = '''\ |
file_contents = '''\ |
1019 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
1020 |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
1021 |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" title="Thuban sample session"> |
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd" title="AltPath Test session"> |
1022 |
<fileshapesource filetype="shapefile" id="D1108450956" filename="../../Data/iceland/political.shp"/> |
<fileshapesource filetype="shapefile" id="D1108450956" filename="../../Data/iceland/political.shp"/> |
1023 |
<fileshapesource filetype="shapefile" id="D1108900076" filename="../Data/iceland/roads-line.shp"/> |
<fileshapesource filetype="shapefile" id="D1108900076" filename="../Data/iceland/roads-line.shp"/> |
1024 |
<fileshapesource filetype="shapefile" id="D1108947244" filename="../../Data/iceland/cultural_landmark-point.shp"/> |
<fileshapesource filetype="shapefile" id="D1108947244" filename="../../Data/iceland/cultural_landmark-point.shp"/> |
1030 |
</session> |
</session> |
1031 |
''' |
''' |
1032 |
|
|
1033 |
|
def checkSession(self, session): |
1034 |
|
"""Check if session has been loaded successfully.""" |
1035 |
|
|
1036 |
|
eq = self.assertEquals |
1037 |
|
|
1038 |
|
map = session.Maps()[0] |
1039 |
|
layers = map.Layers() |
1040 |
|
|
1041 |
|
eq("AltPath Test session", session.Title()) |
1042 |
|
eq("not the iceland map", map.Title()) |
1043 |
|
eq(3,len(layers)) |
1044 |
|
eq("political",layers[0].Title()) |
1045 |
|
eq("roads-line",layers[1].Title()) |
1046 |
|
eq("something else",layers[2].Title()) |
1047 |
|
|
1048 |
def test_01_single_path_error_fix(self): |
def test_01_single_path_error_fix(self): |
1049 |
"""Test single file path error fix.""" |
"""Test single file path error fix.""" |
1050 |
# The usual initial case |
# The usual initial case |
1053 |
"check": [(None, None)]}) |
"check": [(None, None)]}) |
1054 |
self.session = load_session(self.filename(), |
self.session = load_session(self.filename(), |
1055 |
shapefile_callback =s_cb.s_cb) |
shapefile_callback =s_cb.s_cb) |
1056 |
self.session.Destroy() |
self.checkSession(self.session) |
1057 |
self.session = None |
|
|
|
|
1058 |
def test_02_path_error_fix_from_list(self): |
def test_02_path_error_fix_from_list(self): |
1059 |
"""Test single file path error fix.""" |
"""Test single file path error fix.""" |
1060 |
# This represents the usual case for "from_list" |
# This represents the usual case for "from_list" |
1064 |
}) |
}) |
1065 |
self.session = load_session(self.filename(), |
self.session = load_session(self.filename(), |
1066 |
shapefile_callback =s_cb.s_cb) |
shapefile_callback =s_cb.s_cb) |
1067 |
self.session.Destroy() |
self.checkSession(self.session) |
|
self.session = None |
|
1068 |
|
|
1069 |
def test_03_single_path_error_cancelled(self): |
def test_03_single_path_error_cancelled(self): |
1070 |
"""Test alternative path cancelled.""" |
"""Test alternative path cancelled.""" |
1091 |
}) |
}) |
1092 |
self.session = load_session(self.filename(), |
self.session = load_session(self.filename(), |
1093 |
shapefile_callback =s_cb.s_cb) |
shapefile_callback =s_cb.s_cb) |
1094 |
self.session.Destroy() |
self.checkSession(self.session) |
|
self.session = None |
|
1095 |
|
|
1096 |
def test_06_path_error_fix_from_list_fails(self): |
def test_06_path_error_fix_from_list_fails(self): |
1097 |
"""Test alternative path recovery from list.""" |
"""Test alternative path recovery from list.""" |
1105 |
self.assertRaises(IndexError, |
self.assertRaises(IndexError, |
1106 |
s_cb.s_cb, None, "search") |
s_cb.s_cb, None, "search") |
1107 |
|
|
|
self.session.Destroy() |
|
|
self.session = None |
|
1108 |
|
|
1109 |
|
|
1110 |
if __name__ == "__main__": |
if __name__ == "__main__": |