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

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

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

revision 331 by bh, Fri Sep 20 14:34:23 2002 UTC revision 395 by jonathan, Mon Feb 10 15:28:02 2003 UTC
# Line 20  import support Line 20  import support
20  support.initthuban()  support.initthuban()
21    
22  import shapelib  import shapelib
23    import dbflib
24    
25  from Thuban.Model.layer import Layer, SHAPETYPE_POLYGON, SHAPETYPE_ARC, \  from Thuban.Model.layer import Layer, SHAPETYPE_POLYGON, SHAPETYPE_ARC, \
26       SHAPETYPE_POINT       SHAPETYPE_POINT
# Line 96  class TestLayer(unittest.TestCase, suppo Line 97  class TestLayer(unittest.TestCase, suppo
97          shapefilename = self.temp_file_name("layer_empty.shp")          shapefilename = self.temp_file_name("layer_empty.shp")
98          shp = shapelib.create(shapefilename, shapelib.SHPT_POLYGON)          shp = shapelib.create(shapefilename, shapelib.SHPT_POLYGON)
99          shp.close()          shp.close()
100            # create an empty DBF file too because Thuban can't cope yet
101            # with missing DBF file.
102            dbffilename = self.temp_file_name("layer_empty.dbf")
103            dbf = dbflib.create(dbffilename)
104            dbf.add_field("NAME", dbflib.FTString, 20, 0)
105    
106            # Now try to open it.
107          layer = Layer("Empty Layer", shapefilename)          layer = Layer("Empty Layer", shapefilename)
108          self.assertEquals(layer.BoundingBox(), None)          self.assertEquals(layer.BoundingBox(), None)
109          self.assertEquals(layer.LatLongBoundingBox(), None)          self.assertEquals(layer.LatLongBoundingBox(), None)
# Line 140  class TestLayerLegend(unittest.TestCase, Line 147  class TestLayerLegend(unittest.TestCase,
147          # no messages should have been produced          # no messages should have been produced
148          self.check_messages([])          self.check_messages([])
149    
     def test_fill(self):  
         """Test Layer's fill attribute"""  
         # modify the fill  
         self.layer.SetFill(Color(0.5, 1.0, 0.75))  
         self.check_messages([(self.layer, LAYER_LEGEND_CHANGED)])  
         self.assertEquals(self.layer.fill.hex().lower(), "#7fffbf")  
         self.assert_(self.layer.WasModified())  
   
     def test_stroke(self):  
         """Test Layer's stroke attribute"""  
         self.layer.SetStroke(Color(0.5, 1.0, 0.75))  
         self.assertEquals(self.layer.stroke.hex().lower(), "#7fffbf")  
         self.check_messages([(self.layer, LAYER_LEGEND_CHANGED)])  
         self.assert_(self.layer.WasModified())  
   
     def test_stroke_width(self):  
         """Test Layer's stroke_width attribute"""  
         self.layer.SetStrokeWidth(3.0)  
         self.assertEquals(self.layer.stroke_width, 3.0)  
         self.check_messages([(self.layer, LAYER_LEGEND_CHANGED)])  
         self.assert_(self.layer.WasModified())  
   
150      def test_visibility(self):      def test_visibility(self):
151          """Test Layer visibility"""          """Test Layer visibility"""
152          self.layer.SetVisible(0)          self.layer.SetVisible(0)
# Line 172  class TestLayerLegend(unittest.TestCase, Line 157  class TestLayerLegend(unittest.TestCase,
157          # the layer.          # the layer.
158          self.failIf(self.layer.WasModified())          self.failIf(self.layer.WasModified())
159    
160      def test_tree_info(self):      
161          """Test Layer.TreeInfo"""  #
162          self.assertEquals(self.layer.TreeInfo(),  # the tree info now contains Color objects which are difficult to test
163                            ("Layer 'Test Layer'",  #
164                             ['Shown',  #   def test_tree_info(self):
165                              'Shapes: 156',  #       """Test Layer.TreeInfo"""
166                              ('Extent (lat-lon):'  #       self.assertEquals(self.layer.TreeInfo(),
167                               ' (-24.5465, 63.2868, -13.4958, 66.5638)'),  #                         ("Layer 'Test Layer'",
168                              'Shapetype: Polygon',  #                          ['Shown',
169                              'Fill: None',  #                           'Shapes: 156',
170                              'Outline: (0.000, 0.000, 0.000)']))  #                           ('Extent (lat-lon):'
171    #                            ' (-24.5465, 63.2868, -13.4958, 66.5638)'),
172    #                           'Shapetype: Polygon',
173    #                           'Fill: None',
174    #                           'Outline: (0.000, 0.000, 0.000)']))
175    
176    
177  if __name__ == "__main__":  if __name__ == "__main__":

Legend:
Removed from v.331  
changed lines
  Added in v.395

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26