update tests to python api for features
This commit is contained in:
parent
c88d7e723d
commit
4cb9aa44b5
5 changed files with 7 additions and 15 deletions
|
@ -52,7 +52,7 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
eq_(ds.field_types(),['str','str','str','str','float','float','str'])
|
eq_(ds.field_types(),['str','str','str','str','float','float','str'])
|
||||||
feat = ds.featureset().next()
|
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}
|
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_(len(ds.all_features()),2)
|
||||||
eq_(ds.describe(),{'geometry_type': mapnik.DataGeometryType.Point, 'type': mapnik.DataType.Vector, 'name': 'csv', 'encoding': 'utf-8'})
|
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()
|
fs = ds.featureset()
|
||||||
feat = fs.next()
|
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}
|
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:
|
while feat:
|
||||||
eq_(len(feat),10)
|
eq_(len(feat),10)
|
||||||
eq_(feat['empty_column'],u'')
|
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')
|
ds = get_csv_ds('has_attributes_with_slashes.csv')
|
||||||
eq_(len(ds.fields()),3)
|
eq_(len(ds.fields()),3)
|
||||||
fs = ds.all_features()
|
fs = ds.all_features()
|
||||||
eq_(fs[0].describe(),{'x':0,'y':0,'name':u'a/a'})
|
eq_(fs[0].attributes,{'x':0,'y':0,'name':u'a/a'})
|
||||||
eq_(fs[1].describe(),{'x':1,'y':4,'name':u'b/b'})
|
eq_(fs[1].attributes,{'x':1,'y':4,'name':u'b/b'})
|
||||||
eq_(fs[2].describe(),{'x':10,'y':2.5,'name':u'c/c'})
|
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'})
|
eq_(ds.describe(),{'geometry_type': mapnik.DataGeometryType.Point, 'type': mapnik.DataType.Vector, 'name': 'csv', 'encoding': 'utf-8'})
|
||||||
|
|
||||||
def test_wkt_field(**kwargs):
|
def test_wkt_field(**kwargs):
|
||||||
|
|
|
@ -69,7 +69,7 @@ def test_feature_attributes():
|
||||||
features = ds.all_features()
|
features = ds.all_features()
|
||||||
feat = features[0]
|
feat = features[0]
|
||||||
attrs = {'PRFEDEA': u'35043411', 'EAS_ID': 168, 'AREA': 215229.266}
|
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.fields(),['AREA', 'EAS_ID', 'PRFEDEA'])
|
||||||
eq_(ds.field_types(),['float','int','str'])
|
eq_(ds.field_types(),['float','int','str'])
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ def compare_shape_between_mapnik_and_ogr(shapefile,query=None):
|
||||||
#import pdb;pdb.set_trace()
|
#import pdb;pdb.set_trace()
|
||||||
eq_(feat1.id(),feat2.id(),
|
eq_(feat1.id(),feat2.id(),
|
||||||
'%s : ogr feature id %s "%s" does not equal shapefile feature id %s "%s"'
|
'%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
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,6 @@ if 'ogr' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
eq_(f['NOM_FR'], u'Québec')
|
eq_(f['NOM_FR'], u'Québec')
|
||||||
eq_(f['Shape_Area'], 1512185733150.0)
|
eq_(f['Shape_Area'], 1512185733150.0)
|
||||||
eq_(f['Shape_Leng'], 19218883.724300001)
|
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)
|
@raises(RuntimeError)
|
||||||
def test_that_nonexistant_query_field_throws(**kwargs):
|
def test_that_nonexistant_query_field_throws(**kwargs):
|
||||||
|
|
|
@ -38,10 +38,6 @@ if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
eq_(f['NOM_FR'], u'Québec')
|
eq_(f['NOM_FR'], u'Québec')
|
||||||
eq_(f['Shape_Area'], 1512185733150.0)
|
eq_(f['Shape_Area'], 1512185733150.0)
|
||||||
eq_(f['Shape_Leng'], 19218883.724300001)
|
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)
|
@raises(RuntimeError)
|
||||||
def test_that_nonexistant_query_field_throws(**kwargs):
|
def test_that_nonexistant_query_field_throws(**kwargs):
|
||||||
|
|
Loading…
Reference in a new issue