tests: ensure postgis plugin throws if invalid query is made - refs #792

This commit is contained in:
Dane Springmeyer 2011-12-05 12:11:59 -08:00
parent 37fee4b674
commit 0191f9c012

View file

@ -129,6 +129,19 @@ if 'postgis' in mapnik.DatasourceCache.instance().plugin_names() \
feature = fs.next()
eq_(feature,None)
@raises(RuntimeError)
def test_that_nonexistant_query_field_throws(**kwargs):
ds = mapnik.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='empty')
eq_(len(ds.fields()),1)
eq_(ds.fields(),['key'])
eq_(ds.field_types(),['int'])
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)
atexit.register(postgis_takedown)