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

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

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

revision 723 by bh, Thu Apr 24 15:31:53 2003 UTC revision 755 by jonathan, Fri Apr 25 14:48:35 2003 UTC
# Line 114  class SaveSessionTest(unittest.TestCase, Line 114  class SaveSessionTest(unittest.TestCase,
114          <!DOCTYPE session SYSTEM "thuban.dtd">          <!DOCTYPE session SYSTEM "thuban.dtd">
115          <session title="single map&amp;layer">          <session title="single map&amp;layer">
116              <map title="Test Map">              <map title="Test Map">
117                  <projection>                  <projection name="Unknown">
118                      <parameter value="zone=26"/>                      <parameter value="zone=26"/>
119                      <parameter value="proj=utm"/>                      <parameter value="proj=utm"/>
120                      <parameter value="ellps=clrk66"/>                      <parameter value="ellps=clrk66"/>
# Line 129  class SaveSessionTest(unittest.TestCase, Line 129  class SaveSessionTest(unittest.TestCase,
129          #print expected_contents          #print expected_contents
130          self.compare_xml(written_contents, expected_contents)          self.compare_xml(written_contents, expected_contents)
131    
132        def testLayerProjection(self):
133            # deliberately put an apersand in the title :)
134            session = Session("single map&layer")
135            proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"])
136            map = Map("Test Map", projection = proj)
137            session.AddMap(map)
138            # use shapefile from the example data
139            shpfile = os.path.join(os.path.dirname(__file__),
140                                   os.pardir, "Data", "iceland", "political.shp")
141            layer = Layer("My Layer", session.OpenShapefile(shpfile))
142            proj = Projection(["proj=lcc", "ellps=clrk66"], "Layer Projection")
143            layer.SetProjection(proj)
144            map.AddLayer(layer)
145    
146            filename = self.temp_file_name("save_singlemap.thuban")
147            save_session(session, filename)
148            session.Destroy()
149    
150            file = open(filename)
151            written_contents = file.read()
152            file.close()
153            expected_contents = '''<?xml version="1.0" encoding="UTF-8"?>
154            <!DOCTYPE session SYSTEM "thuban.dtd">
155            <session title="single map&amp;layer">
156                <map title="Test Map">
157                    <projection name="Unknown">
158                        <parameter value="zone=26"/>
159                        <parameter value="proj=utm"/>
160                        <parameter value="ellps=clrk66"/>
161                    </projection>
162                    <layer title="My Layer" filename="%s"
163                    fill="None" stroke="#000000" stroke_width="1">
164                        <projection name="Layer Projection">
165                            <parameter value="proj=lcc"/>
166                            <parameter value="ellps=clrk66"/>
167                        </projection>
168                    </layer>
169                </map>
170            </session>''' % os.path.join("..", "..", "Data", "iceland",
171                                         "political.shp")
172            #print written_contents
173            #print "********************************************"
174            #print expected_contents
175            self.compare_xml(written_contents, expected_contents)
176    
177            
178    
179    
180    
181  if __name__ == "__main__":  if __name__ == "__main__":

Legend:
Removed from v.723  
changed lines
  Added in v.755

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26