add more tests for r1121
This commit is contained in:
parent
c8ee43110a
commit
00b2dbb26f
1 changed files with 31 additions and 1 deletions
|
@ -14,4 +14,34 @@ def test_field_listing():
|
||||||
lyr = mapnik.Layer('test')
|
lyr = mapnik.Layer('test')
|
||||||
lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
|
lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
|
||||||
fields = lyr.datasource.fields()
|
fields = lyr.datasource.fields()
|
||||||
eq_(fields, ['AREA', 'EAS_ID', 'PRFEDEA'])
|
eq_(fields, ['AREA', 'EAS_ID', 'PRFEDEA'])
|
||||||
|
|
||||||
|
def test_total_feature_count():
|
||||||
|
lyr = mapnik.Layer('test')
|
||||||
|
lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
|
||||||
|
features = lyr.datasource.all_features()
|
||||||
|
num_feats = len(features)
|
||||||
|
eq_(num_feats, 10)
|
||||||
|
|
||||||
|
def test_feature_envelope():
|
||||||
|
lyr = mapnik.Layer('test')
|
||||||
|
lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
|
||||||
|
features = lyr.datasource.all_features()
|
||||||
|
for feat in features:
|
||||||
|
env = feat.envelope()
|
||||||
|
contains = lyr.envelope().contains(env)
|
||||||
|
eq_(contains, True)
|
||||||
|
intersects = lyr.envelope().contains(env)
|
||||||
|
eq_(intersects, True)
|
||||||
|
|
||||||
|
def test_feature_attributes():
|
||||||
|
lyr = mapnik.Layer('test')
|
||||||
|
lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
|
||||||
|
features = lyr.datasource.all_features()
|
||||||
|
feat = features[0]
|
||||||
|
attrs = {'PRFEDEA': u'35043411', 'EAS_ID': 168, 'AREA': 215229.266}
|
||||||
|
eq_(feat.attributes, attrs)
|
||||||
|
fld_name = 'AREA'
|
||||||
|
fld_idx = lyr.datasource.fields().index(fld_name)
|
||||||
|
eq_(lyr.datasource.field_types()[fld_idx],type(feat.attributes[fld_name]))
|
||||||
|
|
Loading…
Reference in a new issue