tests: ensure shapefile plugin throws if invalid query is made - refs #792
This commit is contained in:
parent
0191f9c012
commit
9cb1c9c7f7
1 changed files with 13 additions and 0 deletions
|
@ -43,6 +43,19 @@ if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
# remove me once the deprecated code is cleaned up
|
# remove me once the deprecated code is cleaned up
|
||||||
eq_(f.properties['Shape_Leng'], 19218883.724300001)
|
eq_(f.properties['Shape_Leng'], 19218883.724300001)
|
||||||
|
|
||||||
|
@raises(RuntimeError)
|
||||||
|
def test_that_nonexistant_query_field_throws(**kwargs):
|
||||||
|
ds = mapnik.Shapefile(file='../data/shp/world_merc')
|
||||||
|
eq_(len(ds.fields()),11)
|
||||||
|
eq_(ds.fields(),['FIPS', 'ISO2', 'ISO3', 'UN', 'NAME', 'AREA', 'POP2005', 'REGION', 'SUBREGION', 'LON', 'LAT'])
|
||||||
|
eq_(ds.field_types(),['str', 'str', 'str', 'int', 'str', 'int', 'int', 'int', 'int', 'float', 'float'])
|
||||||
|
query = mapnik.Query(ds.envelope())
|
||||||
|
for fld in ds.fields():
|
||||||
|
query.add_property_name(fld)
|
||||||
|
# also add an invalid one, triggering throw
|
||||||
|
query.add_property_name('bogus')
|
||||||
|
fs = ds.features(query)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
|
|
Loading…
Reference in a new issue