update tests to python api for features

This commit is contained in:
Dane Springmeyer 2012-01-24 15:16:40 -08:00
parent c88d7e723d
commit 4cb9aa44b5
5 changed files with 7 additions and 15 deletions

View file

@ -52,7 +52,7 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
eq_(ds.field_types(),['str','str','str','str','float','float','str'])
feat = ds.featureset().next()
attr = {'City': u'New York, NY', 'geo_accuracy': u'house', 'Phone': u'(212) 334-0711', 'Address': u'19 Elizabeth Street', 'Precinct': u'5th Precinct', 'geo_longitude': -70, 'geo_latitude': 40}
eq_(feat.describe(),attr)
eq_(feat.attributes,attr)
eq_(len(ds.all_features()),2)
eq_(ds.describe(),{'geometry_type': mapnik.DataGeometryType.Point, 'type': mapnik.DataType.Vector, 'name': 'csv', 'encoding': 'utf-8'})
@ -72,7 +72,7 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
fs = ds.featureset()
feat = fs.next()
attr = {'x': 0, 'empty_column': u'', 'text': u'a b', 'float': 1.0, 'datetime': u'1971-01-01T04:14:00', 'y': 0, 'boolean': u'True', 'time': u'04:14:00', 'date': u'1971-01-01', 'integer': 40}
eq_(feat.describe(),attr)
eq_(feat.attributes,attr)
while feat:
eq_(len(feat),10)
eq_(feat['empty_column'],u'')
@ -83,9 +83,9 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
ds = get_csv_ds('has_attributes_with_slashes.csv')
eq_(len(ds.fields()),3)
fs = ds.all_features()
eq_(fs[0].describe(),{'x':0,'y':0,'name':u'a/a'})
eq_(fs[1].describe(),{'x':1,'y':4,'name':u'b/b'})
eq_(fs[2].describe(),{'x':10,'y':2.5,'name':u'c/c'})
eq_(fs[0].attributes,{'x':0,'y':0,'name':u'a/a'})
eq_(fs[1].attributes,{'x':1,'y':4,'name':u'b/b'})
eq_(fs[2].attributes,{'x':10,'y':2.5,'name':u'c/c'})
eq_(ds.describe(),{'geometry_type': mapnik.DataGeometryType.Point, 'type': mapnik.DataType.Vector, 'name': 'csv', 'encoding': 'utf-8'})
def test_wkt_field(**kwargs):

View file

@ -69,7 +69,7 @@ def test_feature_attributes():
features = ds.all_features()
feat = features[0]
attrs = {'PRFEDEA': u'35043411', 'EAS_ID': 168, 'AREA': 215229.266}
eq_(feat.describe(), attrs)
eq_(feat.attributes, attrs)
eq_(ds.fields(),['AREA', 'EAS_ID', 'PRFEDEA'])
eq_(ds.field_types(),['float','int','str'])

View file

@ -32,7 +32,7 @@ def compare_shape_between_mapnik_and_ogr(shapefile,query=None):
#import pdb;pdb.set_trace()
eq_(feat1.id(),feat2.id(),
'%s : ogr feature id %s "%s" does not equal shapefile feature id %s "%s"'
% (count,feat1.id(),str(feat1.describe()), feat2.id(),str(feat2.describe())))
% (count,feat1.id(),str(feat1.attributes), feat2.id(),str(feat2.attributes)))
return True

View file

@ -40,10 +40,6 @@ if 'ogr' in mapnik.DatasourceCache.instance().plugin_names():
eq_(f['Shape_Area'], 1512185733150.0)
eq_(f['Shape_Leng'], 19218883.724300001)
# Check that the deprecated interface still works,
# remove me once the deprecated code is cleaned up
eq_(f.properties['Shape_Leng'], 19218883.724300001)
@raises(RuntimeError)
def test_that_nonexistant_query_field_throws(**kwargs):
ds = mapnik.Ogr(file='../data/shp/world_merc.shp',layer_by_index=0)

View file

@ -39,10 +39,6 @@ if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
eq_(f['Shape_Area'], 1512185733150.0)
eq_(f['Shape_Leng'], 19218883.724300001)
# Check that the deprecated interface still works,
# remove me once the deprecated code is cleaned up
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')