47 |
Assume that table holds the data of the file |
Assume that table holds the data of the file |
48 |
../Data/iceland/political.dbf sample file. |
../Data/iceland/political.dbf sample file. |
49 |
""" |
""" |
50 |
self.assertEquals(table.record_count(), 156) |
self.assertEquals(table.NumRows(), 156) |
51 |
self.assertEquals(table.field_count(), 8) |
self.assertEquals(table.NumColumns(), 8) |
52 |
|
|
53 |
# Check one each of the possible field types. The width and |
# Check one each of the possible field types. The width and |
54 |
# decimal precision is always 0. |
# decimal precision is always 0. |
55 |
self.assertEquals(table.field_info(0), ('double', 'AREA', 0, 0)) |
columns = table.Columns() |
56 |
self.assertEquals(table.field_info(3), ('int', 'PONET_ID', 0, 0)) |
self.assertEquals(columns[0].name, 'AREA') |
57 |
self.assertEquals(table.field_info(6), ('string', 'POPYCOUN', 0, 0)) |
self.assertEquals(columns[0].type, 'double') |
58 |
|
self.assertEquals(columns[3].name, 'PONET_ID') |
59 |
|
self.assertEquals(columns[3].type, 'int') |
60 |
|
self.assertEquals(columns[6].name, 'POPYCOUN') |
61 |
|
self.assertEquals(columns[6].type, 'string') |
62 |
|
|
63 |
# Read an `interesting' record |
# Read an `interesting' record |
64 |
self.assertEquals(table.read_record(144), |
self.assertEquals(table.ReadRowAsDict(144), |
65 |
{'POPYCOUN': 'IC', 'POPYADMIN': '', 'PONET_': 146, |
{'POPYCOUN': 'IC', 'POPYADMIN': '', 'PONET_': 146, |
66 |
'AREA': 19.462, |
'AREA': 19.462, |
67 |
'POPYTYPE': 1, 'PERIMETER': 88.518000000000001, |
'POPYTYPE': 1, 'PERIMETER': 88.518000000000001, |
72 |
# Therefore we put it last so that we can execute this method |
# Therefore we put it last so that we can execute this method |
73 |
# twice to check whether the other methods still work after the |
# twice to check whether the other methods still work after the |
74 |
# copy |
# copy |
75 |
self.assertEquals(table.field_range("AREA"), |
self.assertEquals(table.ValueRange("AREA"), (0.0, 19.462)) |
|
((0.0, None), (19.462, None))) |
|
76 |
|
|
77 |
unique = table.GetUniqueValues("PONET_ID") |
unique = table.UniqueValues("PONET_ID") |
78 |
unique.sort() |
unique.sort() |
79 |
self.assertEquals(unique, range(1, 157)) |
self.assertEquals(unique, range(1, 157)) |
80 |
|
|
130 |
table = TransientJoinedTable(self.transientdb, landmarks, "CLPTLABEL", |
table = TransientJoinedTable(self.transientdb, landmarks, "CLPTLABEL", |
131 |
auto, "type") |
auto, "type") |
132 |
|
|
133 |
self.assertEquals(table.record_count(), 34) |
self.assertEquals(table.NumRows(), 34) |
134 |
self.assertEquals(table.field_count(), 8) |
self.assertEquals(table.NumColumns(), 8) |
135 |
self.assertEquals(table.field_info(0), ('double', 'AREA', 0, 0)) |
self.assertEquals(table.field_info(0), ('double', 'AREA', 0, 0)) |
136 |
self.assertEquals(table.field_info(7), ('int', 'code', 0, 0)) |
self.assertEquals(table.field_info(7), ('int', 'code', 0, 0)) |
137 |
self.assertEquals(table.field_info(4), ('string', 'CLPTLABEL', 0, 0)) |
self.assertEquals(table.field_info(4), ('string', 'CLPTLABEL', 0, 0)) |
168 |
result2 = table.read_record(3) |
result2 = table.read_record(3) |
169 |
self.assertEquals(result1, result2) |
self.assertEquals(result1, result2) |
170 |
|
|
171 |
|
|
172 |
if __name__ == "__main__": |
if __name__ == "__main__": |
173 |
support.run_tests() |
support.run_tests() |