/[thuban]/branches/WIP-pyshapelib-bramz/test/test_load.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/test/test_load.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1282 by bh, Mon Jun 23 09:47:18 2003 UTC revision 1417 by bh, Tue Jul 15 08:43:53 2003 UTC
# Line 40  import dbflib Line 40  import dbflib
40    
41  from Thuban.Model.save import save_session  from Thuban.Model.save import save_session
42  from Thuban.Model.load import load_session, parse_color, LoadError  from Thuban.Model.load import load_session, parse_color, LoadError
43  from Thuban.Model.color import Color  from Thuban.Model.color import Transparent
44  from Thuban.Model.classification import ClassGroupProperties, ClassGroupRange,\  from Thuban.Model.classification import ClassGroupProperties, ClassGroupRange,\
45      ClassGroupSingleton, ClassGroupDefault      ClassGroupSingleton, ClassGroupDefault
46    
# Line 80  class LoadSessionTest(support.FileLoadTe Line 80  class LoadSessionTest(support.FileLoadTe
80          self.session = None          self.session = None
81    
82    
83      dtd = "http://thuban.intevation.org/dtds/thuban-0.8.dtd"      dtd = "http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"
84      thubanids = [((dtd, n), (None, "id")) for n in      thubanids = [((dtd, n), (None, "id")) for n in
85                   ["fileshapesource", "filetable", "jointable",                   ["fileshapesource", "filetable", "jointable",
86                    "derivedshapesource"]]                    "derivedshapesource"]]
# Line 150  class ClassificationTest(LoadSessionTest Line 150  class ClassificationTest(LoadSessionTest
150                  if data[CLASSES][i][GROUP_TYPE] == "default":                  if data[CLASSES][i][GROUP_TYPE] == "default":
151                      g = ClassGroupDefault(props, data[CLASSES][i][GROUP_LABEL])                      g = ClassGroupDefault(props, data[CLASSES][i][GROUP_LABEL])
152                  elif data[CLASSES][i][GROUP_TYPE] == "range":                  elif data[CLASSES][i][GROUP_TYPE] == "range":
153                      g = ClassGroupRange(data[CLASSES][i][GROUP_DATA][0],                      g = ClassGroupRange((data[CLASSES][i][GROUP_DATA][0],
154                                          data[CLASSES][i][GROUP_DATA][1],                                           data[CLASSES][i][GROUP_DATA][1]),
155                                          props, data[CLASSES][i][GROUP_LABEL])                                          props, data[CLASSES][i][GROUP_LABEL])
156                  elif data[CLASSES][i][GROUP_TYPE] == "single":                  elif data[CLASSES][i][GROUP_TYPE] == "single":
157                      g = ClassGroupSingleton(data[CLASSES][i][GROUP_DATA],                      g = ClassGroupSingleton(data[CLASSES][i][GROUP_DATA],
# Line 167  class TestSingleLayer(LoadSessionTest): Line 167  class TestSingleLayer(LoadSessionTest):
167    
168      file_contents = '''\      file_contents = '''\
169  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
170  <!DOCTYPE session SYSTEM "thuban-0.8.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
171  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"
172          title="single map&amp;layer">          title="single map&amp;layer">
173      <fileshapesource filetype="shapefile" id="D1"      <fileshapesource filetype="shapefile" id="D1"
174          filename="../../Data/iceland/political.shp"/>          filename="../../Data/iceland/political.shp"/>
# Line 214  class TestSingleLayer(LoadSessionTest): Line 214  class TestSingleLayer(LoadSessionTest):
214                                                       os.pardir, os.pardir,                                                       os.pardir, os.pardir,
215                                                       "Data", "iceland",                                                       "Data", "iceland",
216                                                       "political.shp")))                                                       "political.shp")))
217          eq(layer.GetClassification().GetDefaultFill(), Color.Transparent)          eq(layer.GetClassification().GetDefaultFill(), Transparent)
218          eq(layer.GetClassification().GetDefaultLineColor().hex(), "#000000")          eq(layer.GetClassification().GetDefaultLineColor().hex(), "#000000")
219          eq(layer.Visible(), True)          eq(layer.Visible(), True)
220    
# Line 228  class TestLayerVisibility(LoadSessionTes Line 228  class TestLayerVisibility(LoadSessionTes
228    
229      file_contents = '''\      file_contents = '''\
230  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
231  <!DOCTYPE session SYSTEM "thuban-0.8.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
232  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"
233          title="single map&amp;layer">          title="single map&amp;layer">
234      <fileshapesource filetype="shapefile" id="D1"      <fileshapesource filetype="shapefile" id="D1"
235          filename="../../Data/iceland/political.shp"/>          filename="../../Data/iceland/political.shp"/>
# Line 287  class TestClassification(ClassificationT Line 287  class TestClassification(ClassificationT
287                  <clpoint value="1">                  <clpoint value="1">
288                      <cldata stroke="#000000" stroke_width="10" fill="None"/>                      <cldata stroke="#000000" stroke_width="10" fill="None"/>
289                  </clpoint>                  </clpoint>
290                    <clpoint value="\xc3\xa4\xc3\xb6\xc3\xbc"
291                             label="\xc3\x9cml\xc3\xa4uts">
292                        <cldata fill="None" stroke="#000000" stroke_width="1"/>
293                    </clpoint>
294              </classification>              </classification>
295          </layer>          </layer>
296                  <layer title="My Layer 2" stroke_width="1" fill="None"                  <layer title="My Layer 2" stroke_width="1" fill="None"
# Line 321  class TestClassification(ClassificationT Line 325  class TestClassification(ClassificationT
325    
326          map = self.session.Maps()[0] # only one map in the sample          map = self.session.Maps()[0] # only one map in the sample
327    
328          expected = [("My Layer", 2,          expected = [("My Layer", 3,
329                          [("default", (), "",                          [("default", (), "",
330                              ("#000000", 1, "None")),                              ("#000000", 1, "None")),
331                           ("single", "1", "",                           ("single", "1", "",
332                              ("#000000", 2, "None")),                              ("#000000", 2, "None")),
333                           ("single", "1", "",                           ("single", "1", "",
334                              ("#000000", 10, "None"))]),                              ("#000000", 10, "None")),
335                             ("single", "\xe4\xf6\xfc", "\xdcml\xe4uts",
336                                ("#000000", 1, "None"))]),
337                       ("My Layer 2", 4,                       ("My Layer 2", 4,
338                           [("default", (), "",                           [("default", (), "",
339                              ("#000000", 2, "None")),                              ("#000000", 2, "None")),
# Line 347  class TestLabels(ClassificationTest): Line 353  class TestLabels(ClassificationTest):
353    
354      file_contents = '''\      file_contents = '''\
355  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
356  <!DOCTYPE session SYSTEM "thuban-0.8.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
357  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"
358          title="single map&amp;layer">          title="single map&amp;layer">
359      <fileshapesource filetype="shapefile" id="D1"      <fileshapesource filetype="shapefile" id="D1"
360          filename="../../Data/iceland/political.shp"/>          filename="../../Data/iceland/political.shp"/>
# Line 395  class TestLayerProjection(LoadSessionTes Line 401  class TestLayerProjection(LoadSessionTes
401    
402      file_contents = '''\      file_contents = '''\
403  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
404  <!DOCTYPE session SYSTEM "thuban-0.8.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
405  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"
406          title="single map&amp;layer">          title="single map&amp;layer">
407      <fileshapesource filetype="shapefile" id="D2"      <fileshapesource filetype="shapefile" id="D2"
408          filename="../../Data/iceland/roads-line.shp"/>          filename="../../Data/iceland/roads-line.shp"/>
# Line 469  class TestRasterLayer(LoadSessionTest): Line 475  class TestRasterLayer(LoadSessionTest):
475    
476      file_contents = '''\      file_contents = '''\
477  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
478  <!DOCTYPE session SYSTEM "thuban-0.8.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
479  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"
480          title="single map&amp;layer">          title="single map&amp;layer">
481      <map title="Test Map">      <map title="Test Map">
482          <rasterlayer visible="false" filename="../../Data/iceland/island.tif"          <rasterlayer visible="false" filename="../../Data/iceland/island.tif"
# Line 503  class TestRasterLayer(LoadSessionTest): Line 509  class TestRasterLayer(LoadSessionTest):
509  class TestJoinedTable(LoadSessionTest):  class TestJoinedTable(LoadSessionTest):
510    
511      file_contents = '''<?xml version="1.0" encoding="UTF-8"?>      file_contents = '''<?xml version="1.0" encoding="UTF-8"?>
512  <!DOCTYPE session SYSTEM "thuban-0.8.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
513  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd" title="A Joined Table session">  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" title="A Joined Table session">
514      <fileshapesource filetype="shapefile" id="D137227612"      <fileshapesource filetype="shapefile" id="D137227612"
515          filename="../../Data/iceland/roads-line.shp"/>          filename="../../Data/iceland/roads-line.shp"/>
516      <filetable filetype="DBF" filename="load_joinedtable.dbf" id="D136171140"      <filetable filetype="DBF" filename="load_joinedtable.dbf" id="D136171140"
517          title="Some Title"/>          title="Some Title"/>
518      <jointable leftcolumn="RDLNTYPE" right="D136171140"      <jointable id="D136169900" title="Joined"
519          title="Joined" rightcolumn="RDTYPE" id="D136169900" left="D137227612"/>          right="D136171140" left="D137227612"
520            leftcolumn="RDLNTYPE" rightcolumn="RDTYPE"
521            jointype="LEFT OUTER"/>
522      <derivedshapesource table="D136169900" shapesource="D137227612"      <derivedshapesource table="D136169900" shapesource="D137227612"
523          id="D136170932"/>          id="D136170932"/>
524      <map title="Test Map">      <map title="Test Map">
# Line 542  class TestJoinedTable(LoadSessionTest): Line 550  class TestJoinedTable(LoadSessionTest):
550          # FIXME: The tests shouldn't assume a certain order of the tables          # FIXME: The tests shouldn't assume a certain order of the tables
551          self.assertEquals(tables[0].Title(), "Some Title")          self.assertEquals(tables[0].Title(), "Some Title")
552          self.assertEquals(tables[1].Title(), "Joined")          self.assertEquals(tables[1].Title(), "Joined")
553            self.assertEquals(tables[1].JoinType(), "LEFT OUTER")
554          self.check_format()          self.check_format()
555    
556    
# Line 549  class TestLoadError(LoadSessionTest): Line 558  class TestLoadError(LoadSessionTest):
558    
559      file_contents = '''\      file_contents = '''\
560  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
561  <!DOCTYPE session SYSTEM "thuban-0.8.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
562  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"
563          title="single map&amp;layer">          title="single map&amp;layer">
564      <fileshapesource id="D1" filename="../../Data/iceland/political.shp"/>      <fileshapesource id="D1" filename="../../Data/iceland/political.shp"/>
565      <map title="Test Map">      <map title="Test Map">

Legend:
Removed from v.1282  
changed lines
  Added in v.1417

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26