2011-12-03 03:00:20 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
from nose.tools import *
|
|
|
|
from utilities import execution_path
|
|
|
|
|
|
|
|
import mapnik
|
|
|
|
import pickle
|
|
|
|
|
|
|
|
def setup():
|
|
|
|
os.chdir(execution_path('.'))
|
|
|
|
|
|
|
|
def test_parameter():
|
|
|
|
p = mapnik.Parameter('key','value')
|
|
|
|
eq_(p[0],'key')
|
|
|
|
eq_(p[1],'value')
|
|
|
|
|
|
|
|
p = mapnik.Parameter('int',1)
|
|
|
|
eq_(p[0],'int')
|
|
|
|
eq_(p[1],1)
|
|
|
|
|
|
|
|
p = mapnik.Parameter('float',1.0777)
|
|
|
|
eq_(p[0],'float')
|
|
|
|
eq_(p[1],1.0777)
|
|
|
|
|
2012-03-24 04:04:42 +01:00
|
|
|
p = mapnik.Parameter('bool_string','True')
|
|
|
|
eq_(p[0],'bool_string')
|
|
|
|
eq_(p[1],'True')
|
|
|
|
eq_(bool(p[1]),True)
|
|
|
|
|
2011-12-03 03:00:20 +01:00
|
|
|
|
|
|
|
def test_parameters():
|
|
|
|
params = mapnik.Parameters()
|
|
|
|
p = mapnik.Parameter('float',1.0777)
|
|
|
|
eq_(p[0],'float')
|
|
|
|
eq_(p[1],1.0777)
|
2012-02-24 22:13:56 +01:00
|
|
|
|
2011-12-03 03:00:20 +01:00
|
|
|
params.append(p)
|
2012-02-24 22:13:56 +01:00
|
|
|
|
2011-12-03 03:00:20 +01:00
|
|
|
eq_(params[0][0],'float')
|
|
|
|
eq_(params[0][1],1.0777)
|
|
|
|
|
|
|
|
eq_(params.get('float'),1.0777)
|
|
|
|
|
|
|
|
def test_parameters_pickling():
|
|
|
|
params = mapnik.Parameters()
|
|
|
|
params.append(mapnik.Parameter('oh',str('yeah')))
|
2012-02-24 22:13:56 +01:00
|
|
|
|
2011-12-03 03:00:20 +01:00
|
|
|
params2 = pickle.loads(pickle.dumps(params,pickle.HIGHEST_PROTOCOL))
|
|
|
|
|
|
|
|
eq_(params[0][0],params2[0][0])
|
|
|
|
eq_(params[0][1],params2[0][1])
|
2012-02-24 22:13:56 +01:00
|
|
|
|
2011-12-03 03:00:20 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
setup()
|
|
|
|
[eval(run)() for run in dir() if 'test_' in run]
|