1016 |
file_contents = '''\ |
file_contents = '''\ |
1017 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
1018 |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
<!DOCTYPE session SYSTEM "thuban-1.1.dtd"> |
1019 |
<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"> |
1020 |
<fileshapesource filetype="shapefile" id="D1108450956" filename="../../Data/iceland/political.shp"/> |
<fileshapesource filetype="shapefile" id="D1108450956" filename="../../Data/iceland/political.shp"/> |
1021 |
<fileshapesource filetype="shapefile" id="D1108900076" filename="../Data/iceland/roads-line.shp"/> |
<fileshapesource filetype="shapefile" id="D1108900076" filename="../Data/iceland/roads-line.shp"/> |
1022 |
<fileshapesource filetype="shapefile" id="D1108947244" filename="../../Data/iceland/cultural_landmark-point.shp"/> |
<fileshapesource filetype="shapefile" id="D1108947244" filename="../../Data/iceland/cultural_landmark-point.shp"/> |
1028 |
</session> |
</session> |
1029 |
''' |
''' |
1030 |
|
|
1031 |
|
def checkSession(self, session): |
1032 |
|
"""Check if session has been loaded successfully.""" |
1033 |
|
|
1034 |
|
eq = self.assertEquals |
1035 |
|
|
1036 |
|
map = session.Maps()[0] |
1037 |
|
layers = map.Layers() |
1038 |
|
|
1039 |
|
eq("AltPath Test session", session.Title()) |
1040 |
|
eq("not the iceland map", map.Title()) |
1041 |
|
eq(3,len(layers)) |
1042 |
|
eq("political",layers[0].Title()) |
1043 |
|
eq("roads-line",layers[1].Title()) |
1044 |
|
eq("something else",layers[2].Title()) |
1045 |
|
|
1046 |
def test_01_single_path_error_fix(self): |
def test_01_single_path_error_fix(self): |
1047 |
"""Test single file path error fix.""" |
"""Test single file path error fix.""" |
1048 |
|
|
1049 |
|
eq = self.assertEquals |
1050 |
|
|
1051 |
# The usual initial case |
# The usual initial case |
1052 |
s_cb = Shapefile_CallBack({ |
s_cb = Shapefile_CallBack({ |
1053 |
"search": [("../Data/iceland/roads-line.shp",0)], |
"search": [("../Data/iceland/roads-line.shp",0)], |
1054 |
"check": [(None, None)]}) |
"check": [(None, None)]}) |
1055 |
self.session = load_session(self.filename(), |
self.session = load_session(self.filename(), |
1056 |
shapefile_callback =s_cb.s_cb) |
shapefile_callback =s_cb.s_cb) |
1057 |
|
self.checkSession(self.session) |
1058 |
|
|
1059 |
def test_02_path_error_fix_from_list(self): |
def test_02_path_error_fix_from_list(self): |
1060 |
"""Test single file path error fix.""" |
"""Test single file path error fix.""" |
1061 |
# This represents the usual case for "from_list" |
# This represents the usual case for "from_list" |
1065 |
}) |
}) |
1066 |
self.session = load_session(self.filename(), |
self.session = load_session(self.filename(), |
1067 |
shapefile_callback =s_cb.s_cb) |
shapefile_callback =s_cb.s_cb) |
1068 |
|
self.checkSession(self.session) |
1069 |
|
|
1070 |
def test_03_single_path_error_cancelled(self): |
def test_03_single_path_error_cancelled(self): |
1071 |
"""Test alternative path cancelled.""" |
"""Test alternative path cancelled.""" |
1092 |
}) |
}) |
1093 |
self.session = load_session(self.filename(), |
self.session = load_session(self.filename(), |
1094 |
shapefile_callback =s_cb.s_cb) |
shapefile_callback =s_cb.s_cb) |
1095 |
|
self.checkSession(self.session) |
1096 |
|
|
1097 |
def test_06_path_error_fix_from_list_fails(self): |
def test_06_path_error_fix_from_list_fails(self): |
1098 |
"""Test alternative path recovery from list.""" |
"""Test alternative path recovery from list.""" |