more tests for object stringify in geojson plugin - refs #2678
This commit is contained in:
parent
3aaac077cb
commit
df60a2f37f
1 changed files with 28 additions and 0 deletions
|
@ -4,6 +4,10 @@
|
|||
from nose.tools import eq_,assert_almost_equal
|
||||
from utilities import execution_path, run_all
|
||||
import os, mapnik
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
def setup():
|
||||
# All of the paths used are relative, if we run the tests
|
||||
|
@ -35,6 +39,12 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names():
|
|||
eq_(f['boolean'], True)
|
||||
eq_(f['NOM_FR'], u'Qu\xe9bec')
|
||||
eq_(f['NOM_FR'], u'Québec')
|
||||
eq_(f['array'], u'[[[1],["deux"]],[["\\u0442\\u0440\\u0438","four","\\u4e94"]]]')
|
||||
array = json.loads(f['array'])
|
||||
eq_(array,[[[1], [u'deux']], [[u'\u0442\u0440\u0438', u'four', u'\u4e94']]])
|
||||
eq_(f['object'], u'{"value":{"type":"\\u041c\\u0430pni\\u043a","array":[3,0,"x"]}}')
|
||||
object = json.loads(f['object'])
|
||||
eq_(object,{u'value': {u'array': [3, 0, u'x'], u'type': u'\u041c\u0430pni\u043a'}})
|
||||
|
||||
ds = mapnik.Datasource(type='geojson',file='../data/json/escaped.geojson')
|
||||
f = ds.all_features()[0]
|
||||
|
@ -51,6 +61,12 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names():
|
|||
eq_(f['boolean'], True)
|
||||
eq_(f['NOM_FR'], u'Qu\xe9bec')
|
||||
eq_(f['NOM_FR'], u'Québec')
|
||||
eq_(f['array'], u'[[[1],["deux"]],[["\\u0442\\u0440\\u0438","four","\\u4e94"]]]')
|
||||
array = json.loads(f['array'])
|
||||
eq_(array,[[[1], [u'deux']], [[u'\u0442\u0440\u0438', u'four', u'\u4e94']]])
|
||||
eq_(f['object'], u'{"value":{"type":"\\u041c\\u0430pni\\u043a","array":[3,0,"x"]}}')
|
||||
object = json.loads(f['object'])
|
||||
eq_(object,{u'value': {u'array': [3, 0, u'x'], u'type': u'\u041c\u0430pni\u043a'}})
|
||||
|
||||
def test_large_geojson_properties():
|
||||
ds = mapnik.Datasource(type='geojson',file='../data/json/escaped.geojson',cache_features = False)
|
||||
|
@ -67,6 +83,12 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names():
|
|||
eq_(f['boolean'], True)
|
||||
eq_(f['NOM_FR'], u'Qu\xe9bec')
|
||||
eq_(f['NOM_FR'], u'Québec')
|
||||
eq_(f['array'], u'[[[1],["deux"]],[["\\u0442\\u0440\\u0438","four","\\u4e94"]]]')
|
||||
array = json.loads(f['array'])
|
||||
eq_(array,[[[1], [u'deux']], [[u'\u0442\u0440\u0438', u'four', u'\u4e94']]])
|
||||
eq_(f['object'], u'{"value":{"type":"\\u041c\\u0430pni\\u043a","array":[3,0,"x"]}}')
|
||||
object = json.loads(f['object'])
|
||||
eq_(object,{u'value': {u'array': [3, 0, u'x'], u'type': u'\u041c\u0430pni\u043a'}})
|
||||
|
||||
ds = mapnik.Datasource(type='geojson',file='../data/json/escaped.geojson')
|
||||
f = ds.all_features()[0]
|
||||
|
@ -83,6 +105,12 @@ if 'geojson' in mapnik.DatasourceCache.plugin_names():
|
|||
eq_(f['boolean'], True)
|
||||
eq_(f['NOM_FR'], u'Qu\xe9bec')
|
||||
eq_(f['NOM_FR'], u'Québec')
|
||||
eq_(f['array'], u'[[[1],["deux"]],[["\\u0442\\u0440\\u0438","four","\\u4e94"]]]')
|
||||
array = json.loads(f['array'])
|
||||
eq_(array,[[[1], [u'deux']], [[u'\u0442\u0440\u0438', u'four', u'\u4e94']]])
|
||||
eq_(f['object'], u'{"value":{"type":"\\u041c\\u0430pni\\u043a","array":[3,0,"x"]}}')
|
||||
object = json.loads(f['object'])
|
||||
eq_(object,{u'value': {u'array': [3, 0, u'x'], u'type': u'\u041c\u0430pni\u043a'}})
|
||||
|
||||
def test_geojson_from_in_memory_string():
|
||||
# will silently fail since it is a geometry and needs to be a featurecollection.
|
||||
|
|
Loading…
Add table
Reference in a new issue