3
from nose.tools import *
4
from utilities import execution_path
9
# All of the paths used are relative, if we run the tests
10
# from another directory we need to chdir()
11
os.chdir(execution_path('.'))
13
def test_field_listing():
14
lyr = mapnik.Layer('test')
15
lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
16
fields = lyr.datasource.fields()
17
eq_(fields, ['AREA', 'EAS_ID', 'PRFEDEA'])
19
def test_total_feature_count():
20
lyr = mapnik.Layer('test')
21
lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
22
features = lyr.datasource.all_features()
23
num_feats = len(features)
26
def test_feature_envelope():
27
lyr = mapnik.Layer('test')
28
lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
29
features = lyr.datasource.all_features()
32
contains = lyr.envelope().contains(env)
34
intersects = lyr.envelope().contains(env)
37
def test_feature_attributes():
38
lyr = mapnik.Layer('test')
39
lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
40
features = lyr.datasource.all_features()
42
attrs = {'PRFEDEA': u'35043411', 'EAS_ID': 168, 'AREA': 215229.266}
43
eq_(feat.attributes, attrs)
45
fld_idx = lyr.datasource.fields().index(fld_name)
46
eq_(lyr.datasource.field_types()[fld_idx],type(feat.attributes[fld_name]))
b'\\ No newline at end of file'