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

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

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

revision 584 by jonathan, Tue Apr 1 10:22:35 2003 UTC revision 851 by bh, Wed May 7 15:11:12 2003 UTC
# Line 1  Line 1 
1  # Copyright (c) 2002 by Intevation GmbH  # Copyright (c) 2002, 2003 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 38  class TestSessionSimple(unittest.TestCas Line 38  class TestSessionSimple(unittest.TestCas
38          session = Session("Test Session")          session = Session("Test Session")
39          self.assertEquals(session.Title(), "Test Session")          self.assertEquals(session.Title(), "Test Session")
40          self.assertEquals(session.Maps(), [])          self.assertEquals(session.Maps(), [])
41            self.assertEquals(session.Tables(), [])
42            self.assertEquals(session.ShapeStores(), [])
43          self.assertEquals(session.filename, None)          self.assertEquals(session.filename, None)
44          self.failIf(session.HasMaps())          self.failIf(session.HasMaps())
45          self.failIf(session.WasModified())          self.failIf(session.WasModified())
# Line 71  class TestSessionBase(unittest.TestCase, Line 73  class TestSessionBase(unittest.TestCase,
73      def tearDown(self):      def tearDown(self):
74          """Destroy self.session and clear the message list"""          """Destroy self.session and clear the message list"""
75          self.session.Destroy()          self.session.Destroy()
76            self.session = None
77          self.clear_messages()          self.clear_messages()
78    
79    
# Line 105  class TestSessionWithContent(TestSession Line 108  class TestSessionWithContent(TestSession
108          """Extend the inherited method to add a non-empty map to self.session          """Extend the inherited method to add a non-empty map to self.session
109          """          """
110          TestSessionBase.setUp(self)          TestSessionBase.setUp(self)
111            open_shp = self.session.OpenShapefile
112          self.arc_layer = Layer("Roads",          self.arc_layer = Layer("Roads",
113                                 os.path.join("..", "Data", "iceland",                                 open_shp(os.path.join("..", "Data", "iceland",
114                                              "roads-line.shp"))                                                       "roads-line.shp")))
115          self.poly_layer = Layer("Political",          self.poly_layer = Layer("Political",
116                                  os.path.join("..", "Data", "iceland",                                  open_shp(os.path.join("..", "Data", "iceland",
117                                               "political.shp"))                                                        "political.shp")))
118          self.map = Map("A Map")          self.map = Map("A Map")
119          self.map.AddLayer(self.arc_layer)          self.map.AddLayer(self.arc_layer)
120          self.map.AddLayer(self.poly_layer)          self.map.AddLayer(self.poly_layer)
# Line 118  class TestSessionWithContent(TestSession Line 122  class TestSessionWithContent(TestSession
122          self.session.UnsetModified()          self.session.UnsetModified()
123          self.clear_messages()          self.clear_messages()
124    
125        def tearDown(self):
126            TestSessionBase.tearDown(self)
127            self.arc_layer = self.poly_layer = None
128    
129      def test_remove_map(self):      def test_remove_map(self):
130          """Test Session.RemoveMap"""          """Test Session.RemoveMap"""
131          self.session.RemoveMap(self.map)          self.session.RemoveMap(self.map)
# Line 201  class TestSessionWithContent(TestSession Line 209  class TestSessionWithContent(TestSession
209                               (self.session, CHANGED),                               (self.session, CHANGED),
210                               (CHANGED,)])                               (CHANGED,)])
211    
212        def test_shape_stores(self):
213            """Test Session.ShapeStores()"""
214            # Strictly speaking the session doesn't make guarantees about
215            # the order of the ShapeStores in the list, but currently it's
216            # deterministic and they're listed in the order in which they
217            # were created
218            self.assertEquals(self.session.ShapeStores(),
219                              [self.arc_layer.ShapeStore(),
220                               self.poly_layer.ShapeStore()])
221            # If we remove the map from the session and clear our instance
222            # variables that hold the layers and the map the list should
223            # become empty again.
224            self.session.RemoveMap(self.map)
225            self.arc_layer = self.poly_layer = self.map = None
226            self.assertEquals(self.session.ShapeStores(), [])
227    
228        def test_tables(self):
229            """Test Session.Tables()"""
230            # Strictly speaking the session doesn't make guarantees about
231            # the order of the tables in the list, but currently it's
232            # deterministic and they're listed in the order in which they
233            # were opened
234            self.assertEquals(self.session.Tables(),
235                              [self.arc_layer.ShapeStore().Table(),
236                               self.poly_layer.ShapeStore().Table()])
237            # If we remove the map from the session and clear our instance
238            # variables that hold the layers and the map the list should
239            # become empty again.
240            self.session.RemoveMap(self.map)
241            self.arc_layer = self.poly_layer = self.map = None
242            self.assertEquals(self.session.Tables(), [])
243    
244    
245  if __name__ == "__main__":  if __name__ == "__main__":
246      unittest.main()      unittest.main()

Legend:
Removed from v.584  
changed lines
  Added in v.851

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26