/[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 839 by bh, Tue May 6 15:54:18 2003 UTC revision 845 by bh, Tue May 6 18:05:13 2003 UTC
# Line 118  class TestTransientTable(unittest.TestCa Line 118  class TestTransientTable(unittest.TestCa
118          self.run_iceland_political_tests(table)          self.run_iceland_political_tests(table)
119          self.run_iceland_political_tests(table)          self.run_iceland_political_tests(table)
120    
121        def test_auto_transient_table_query(self):
122            """Test AutoTransientTable.SimpleQuery()"""
123            orig_table = DBFTable(os.path.join("..", "Data", "iceland",
124                                               "political.dbf"))
125            table = AutoTransientTable(self.transientdb, orig_table)
126            # Only a simple test here. The AutoTransientTable siply
127            # delegates to its transient table so it should be OK that the
128            # real test for it is in test_transient_table_query. However,
129            # it's important to check that the column handling works
130            # correctly because the AutoTransientTable and it's underlying
131            # transient table use different column object types.
132            self.assertEquals(table.SimpleQuery(table.Column("AREA"), ">", 10.0),
133                              [144])
134    
135      def test_transient_joined_table(self):      def test_transient_joined_table(self):
136          """Test TransientJoinedTable"""          """Test TransientJoinedTable"""
# Line 164  class TestTransientTable(unittest.TestCa Line 177  class TestTransientTable(unittest.TestCa
177    
178    
179      def test_transient_table_read_twice(self):      def test_transient_table_read_twice(self):
180          """Test TransientTable.read_record() reading the same record twice"""          """Test TransientTable.ReadRowAsDict() reading the same record twice"""
181          simple = MemoryTable([("type", FIELDTYPE_STRING),          simple = MemoryTable([("type", FIELDTYPE_STRING),
182                                ("code", FIELDTYPE_INT)],                                ("code", FIELDTYPE_INT)],
183                               [("OTHER/UNKNOWN", 0),                               [("OTHER/UNKNOWN", 0),
# Line 185  class TestTransientTable(unittest.TestCa Line 198  class TestTransientTable(unittest.TestCa
198          self.assertEquals(result1, result2)          self.assertEquals(result1, result2)
199    
200    
201        def test_transient_table_query(self):
202            """Test TransientTable.SimpleQuery()"""
203            simple = MemoryTable([("type", FIELDTYPE_STRING),
204                                  ("value", FIELDTYPE_DOUBLE),
205                                  ("code", FIELDTYPE_INT)],
206                                 [("OTHER/UNKNOWN", -1.5, 11),
207                                  ("RUINS", 0.0, 1),
208                                  ("FARM", 3.141, 2),
209                                  ("BUILDING", 2.5, 3),
210                                  ("HUT", 1e6, 4),
211                                  ("LIGHTHOUSE", -0.01, 5)])
212            table = TransientTable(self.transientdb, simple)
213    
214            # A column and a value
215            self.assertEquals(table.SimpleQuery(table.Column(0), "==", "RUINS"),
216                              [1])
217            self.assertEquals(table.SimpleQuery(table.Column(2), "!=", 2),
218                              [0, 1, 3, 4, 5])
219            self.assertEquals(table.SimpleQuery(table.Column(1), "<", 1.0),
220                              [0, 1, 5])
221            self.assertEquals(table.SimpleQuery(table.Column(1), "<=", -1.5),
222                              [0])
223            self.assertEquals(table.SimpleQuery(table.Column(2), ">", 3),
224                              [0, 4, 5])
225            self.assertEquals(table.SimpleQuery(table.Column(2), ">=", 3),
226                              [0, 3, 4, 5])
227    
228            # Two columns as operands
229            self.assertEquals(table.SimpleQuery(table.Column(1),
230                                                "<=", table.Column(2)),
231                              [0, 1, 3, 5])
232    
233            # Test whether invalid operators raise a ValueError
234            self.assertRaises(ValueError,
235                              table.SimpleQuery,
236                              table.Column(1), "<<", table.Column(2))
237    
238    
239  if __name__ == "__main__":  if __name__ == "__main__":
240      support.run_tests()      support.run_tests()

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26