/[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 845 by bh, Tue May 6 18:05:13 2003 UTC revision 998 by bh, Thu May 22 19:29:39 2003 UTC
# Line 67  class TestTransientTable(unittest.TestCa Line 67  class TestTransientTable(unittest.TestCa
67          self.failIf(table.HasColumn("non_existing_name"))          self.failIf(table.HasColumn("non_existing_name"))
68          self.failIf(table.HasColumn(100))          self.failIf(table.HasColumn(100))
69    
70          # Read an `interesting' record          # Reading rows and values.
71          self.assertEquals(table.ReadRowAsDict(144),          self.assertEquals(table.ReadRowAsDict(144),
72                            {'POPYCOUN': 'IC', 'POPYADMIN': '', 'PONET_': 146,                            {'POPYCOUN': 'IC', 'POPYADMIN': '', 'PONET_': 146,
73                             'AREA': 19.462,                             'AREA': 19.462,
74                             'POPYTYPE': 1, 'PERIMETER': 88.518000000000001,                             'POPYTYPE': 1, 'PERIMETER': 88.518000000000001,
75                             'POPYREG': '1',                             'POPYREG': '1',
76                             'PONET_ID': 145})                             'PONET_ID': 145})
77            self.assertEquals(table.ReadValue(144, "AREA"), 19.462)
78            self.assertEquals(table.ReadValue(144, 3), 145)
79    
80          # ValueRange may induce a copy to the transient database.          # ValueRange may induce a copy to the transient database.
81          # Therefore we put it last so that we can execute this method          # Therefore we put it last so that we can execute this method
# Line 99  class TestTransientTable(unittest.TestCa Line 101  class TestTransientTable(unittest.TestCa
101          # The transient_table method should return the table itself          # The transient_table method should return the table itself
102          self.assert_(table is table.transient_table())          self.assert_(table is table.transient_table())
103    
104            # The title is simply copied over from the original table
105            self.assertEquals(table.Title(), orig_table.Title())
106    
107            # The TransientTable class itself doesn't implement the
108            # Dependencies method, so we don't test it.
109    
110    
111      def test_auto_transient_table(self):      def test_auto_transient_table(self):
112          """Test AutoTransientTable(dbftable)          """Test AutoTransientTable(dbftable)
# Line 123  class TestTransientTable(unittest.TestCa Line 131  class TestTransientTable(unittest.TestCa
131          orig_table = DBFTable(os.path.join("..", "Data", "iceland",          orig_table = DBFTable(os.path.join("..", "Data", "iceland",
132                                             "political.dbf"))                                             "political.dbf"))
133          table = AutoTransientTable(self.transientdb, orig_table)          table = AutoTransientTable(self.transientdb, orig_table)
134          # Only a simple test here. The AutoTransientTable siply          # Only a simple test here. The AutoTransientTable simply
135          # delegates to its transient table so it should be OK that the          # delegates to its transient table so it should be OK that the
136          # real test for it is in test_transient_table_query. However,          # real test for it is in test_transient_table_query. However,
137          # it's important to check that the column handling works          # it's important to check that the column handling works
# Line 132  class TestTransientTable(unittest.TestCa Line 140  class TestTransientTable(unittest.TestCa
140          self.assertEquals(table.SimpleQuery(table.Column("AREA"), ">", 10.0),          self.assertEquals(table.SimpleQuery(table.Column("AREA"), ">", 10.0),
141                            [144])                            [144])
142    
143            # test using a Column object as the right parameter
144            self.assertEquals(table.SimpleQuery(table.Column("POPYTYPE"),
145                                                "==",
146                                                table.Column("POPYREG")),
147                              range(156))
148    
149        def test_auto_transient_table_dependencies(self):
150            """Test AutoTransientTable.Dependencies()"""
151            orig_table = DBFTable(os.path.join("..", "Data", "iceland",
152                                               "political.dbf"))
153            table = AutoTransientTable(self.transientdb, orig_table)
154            self.assertEquals(table.Dependencies(), (orig_table,))
155    
156        def test_auto_transient_table_title(self):
157            """Test AutoTransientTable.Title()"""
158            orig_table = DBFTable(os.path.join("..", "Data", "iceland",
159                                               "political.dbf"))
160            table = AutoTransientTable(self.transientdb, orig_table)
161            # The title is of course the same as that of the original table
162            self.assertEquals(table.Title(), orig_table.Title())
163    
164      def test_transient_joined_table(self):      def test_transient_joined_table(self):
165          """Test TransientJoinedTable"""          """Test TransientJoinedTable"""
166          simple = MemoryTable([("type", FIELDTYPE_STRING),          simple = MemoryTable([("type", FIELDTYPE_STRING),
# Line 165  class TestTransientTable(unittest.TestCa Line 194  class TestTransientTable(unittest.TestCa
194          self.failIf(table.HasColumn("non_existing_name"))          self.failIf(table.HasColumn("non_existing_name"))
195          self.failIf(table.HasColumn(100))          self.failIf(table.HasColumn(100))
196    
197          # Read an `interesting' record          # Reading rows and values
198          self.assertEquals(table.ReadRowAsDict(22),          self.assertEquals(table.ReadRowAsDict(22),
199                            {'PERIMETER': 0.0, 'CLPOINT_': 23,                            {'PERIMETER': 0.0, 'CLPOINT_': 23,
200                             'AREA': 0.0, 'CLPTLABEL': 'RUINS',                             'AREA': 0.0, 'CLPTLABEL': 'RUINS',
201                             'CLPOINT_ID': 38, 'CLPTFLAG': 0,                             'CLPOINT_ID': 38, 'CLPTFLAG': 0,
202                             'code': 1, 'type': 'RUINS'})                             'code': 1, 'type': 'RUINS'})
203            self.assertEquals(table.ReadValue(22, "type"), 'RUINS')
204            self.assertEquals(table.ReadValue(22, 7), 1)
205    
206          # The transient_table method should return the table itself          # The transient_table method should return the table itself
207          self.assert_(table is table.transient_table())          self.assert_(table is table.transient_table())
208    
209            # The TransientJoinedTable depends on both input tables
210            self.assertEquals(table.Dependencies(), (landmarks, auto))
211    
212            # The title is constructed from the titles of the input tables.
213            self.assertEquals(table.Title(),
214                              "Join of %s and %s" % (landmarks.Title(),
215                                                     auto.Title()))
216    
217    
218      def test_transient_table_read_twice(self):      def test_transient_table_read_twice(self):
219          """Test TransientTable.ReadRowAsDict() reading the same record twice"""          """Test TransientTable.ReadRowAsDict() reading the same record twice"""

Legend:
Removed from v.845  
changed lines
  Added in v.998

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26