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

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

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

revision 804 by bh, Wed Apr 30 10:54:03 2003 UTC revision 805 by jan, Fri May 2 16:42:35 2003 UTC
# Line 19  import unittest Line 19  import unittest
19  import support  import support
20  support.initthuban()  support.initthuban()
21    
22  from Thuban.Model.table import DBFTable, FIELDTYPE_STRING, FIELDTYPE_INT  from Thuban.Model.table import DBFTable, MemoryTable, FIELDTYPE_STRING, \
23                                   FIELDTYPE_INT
24  from Thuban.Model.transientdb import TransientDatabase, TransientTable, \  from Thuban.Model.transientdb import TransientDatabase, TransientTable, \
25       TransientJoinedTable, AutoTransientTable       TransientJoinedTable, AutoTransientTable
26    
27    
 class SimpleTable:  
   
     """Very simple table implementation that operates on a list of tuples"""  
   
     def __init__(self, fields, data):  
         """Initialize the SimpleTable  
   
         Parameters:  
         fields -- List of (name, field_type) pairs  
         data -- List of tuples, one for each row of data  
         """  
         self.fields = fields  
         self.data = data  
   
     def field_count(self):  
         return len(self.fields)  
   
     def field_info(self, index):  
         name, type = self.fields[index]  
         return (type, name, 0, 0)  
   
     def record_count(self):  
         return len(self.data)  
   
     def read_record(self, index):  
         return dict([(self.fields[i][0], self.data[index][i])  
                       for i in range(len(self.fields))])  
   
   
28  class TestTransientTable(unittest.TestCase, support.FileTestMixin):  class TestTransientTable(unittest.TestCase, support.FileTestMixin):
29    
30      def setUp(self):      def setUp(self):
# Line 139  class TestTransientTable(unittest.TestCa Line 111  class TestTransientTable(unittest.TestCa
111    
112      def test_transient_joined_table(self):      def test_transient_joined_table(self):
113          """Test TransientJoinedTable"""          """Test TransientJoinedTable"""
114          simple = SimpleTable([("type", FIELDTYPE_STRING),          simple = MemoryTable([("type", FIELDTYPE_STRING),
115                                ("code", FIELDTYPE_INT)],                                ("code", FIELDTYPE_INT)],
116                               [("OTHER/UNKNOWN", 0),                               [("OTHER/UNKNOWN", 0),
117                                ("RUINS", 1),                                ("RUINS", 1),
# Line 174  class TestTransientTable(unittest.TestCa Line 146  class TestTransientTable(unittest.TestCa
146    
147      def test_transient_table_read_twice(self):      def test_transient_table_read_twice(self):
148          """Test TransientTable.read_record() reading the same record twice"""          """Test TransientTable.read_record() reading the same record twice"""
149          simple = SimpleTable([("type", FIELDTYPE_STRING),          simple = MemoryTable([("type", FIELDTYPE_STRING),
150                                ("code", FIELDTYPE_INT)],                                ("code", FIELDTYPE_INT)],
151                               [("OTHER/UNKNOWN", 0),                               [("OTHER/UNKNOWN", 0),
152                                ("RUINS", 1),                                ("RUINS", 1),

Legend:
Removed from v.804  
changed lines
  Added in v.805

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26