/[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 723 by bh, Thu Apr 24 15:31:53 2003 UTC revision 982 by bh, Thu May 22 12:02:15 2003 UTC
# Line 27  from Thuban.Model.map import Map Line 27  from Thuban.Model.map import Map
27  from Thuban.Model.layer import Layer  from Thuban.Model.layer import Layer
28  from Thuban.Model.proj import Projection  from Thuban.Model.proj import Projection
29  from Thuban.Model.color import Color  from Thuban.Model.color import Color
30    from Thuban.Model.table import MemoryTable, FIELDTYPE_STRING, \
31                                   FIELDTYPE_INT, FIELDTYPE_DOUBLE
32    
33  class TestSessionSimple(unittest.TestCase):  class TestSessionSimple(unittest.TestCase):
34    
# Line 38  class TestSessionSimple(unittest.TestCas Line 39  class TestSessionSimple(unittest.TestCas
39          session = Session("Test Session")          session = Session("Test Session")
40          self.assertEquals(session.Title(), "Test Session")          self.assertEquals(session.Title(), "Test Session")
41          self.assertEquals(session.Maps(), [])          self.assertEquals(session.Maps(), [])
42            self.assertEquals(session.Tables(), [])
43            self.assertEquals(session.ShapeStores(), [])
44          self.assertEquals(session.filename, None)          self.assertEquals(session.filename, None)
45          self.failIf(session.HasMaps())          self.failIf(session.HasMaps())
46          self.failIf(session.WasModified())          self.failIf(session.WasModified())
47          session.Destroy()          session.Destroy()
48    
49        def test_add_table(self):
50            """Test Session.AddTable()"""
51            session = Session("Test Session")
52            memtable = MemoryTable([("type", FIELDTYPE_STRING),
53                                    ("value", FIELDTYPE_DOUBLE),
54                                    ("code", FIELDTYPE_INT)],
55                                   [("OTHER/UNKNOWN", -1.5, 11),
56                                    ("RUINS", 0.0, 1),
57                                    ("FARM", 3.141, 2),
58                                    ("BUILDING", 2.5, 3),
59                                    ("HUT", 1e6, 4),
60                                    ("LIGHTHOUSE", -0.01, 5)])
61            table = session.AddTable(memtable)
62            self.assertEquals(session.Tables(), [table])
63    
64    
65  class TestSessionBase(unittest.TestCase, support.SubscriberMixin):  class TestSessionBase(unittest.TestCase, support.SubscriberMixin):
66    
# Line 207  class TestSessionWithContent(TestSession Line 225  class TestSessionWithContent(TestSession
225                               (self.session, CHANGED),                               (self.session, CHANGED),
226                               (CHANGED,)])                               (CHANGED,)])
227    
228        def test_shape_stores(self):
229            """Test Session.ShapeStores()"""
230            # Strictly speaking the session doesn't make guarantees about
231            # the order of the ShapeStores in the list, but currently it's
232            # deterministic and they're listed in the order in which they
233            # were created
234            self.assertEquals(self.session.ShapeStores(),
235                              [self.arc_layer.ShapeStore(),
236                               self.poly_layer.ShapeStore()])
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.ShapeStores(), [])
243    
244        def test_tables(self):
245            """Test Session.Tables()"""
246            # Strictly speaking the session doesn't make guarantees about
247            # the order of the tables in the list, but currently it's
248            # deterministic and they're listed in the order in which they
249            # were opened
250            self.assertEquals(self.session.Tables(),
251                              [self.arc_layer.ShapeStore().Table(),
252                               self.poly_layer.ShapeStore().Table()])
253            # If we remove the map from the session and clear our instance
254            # variables that hold the layers and the map the list should
255            # become empty again.
256            self.session.RemoveMap(self.map)
257            self.arc_layer = self.poly_layer = self.map = None
258            self.assertEquals(self.session.Tables(), [])
259    
260    
261  if __name__ == "__main__":  if __name__ == "__main__":
262      unittest.main()      unittest.main()

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26