2011-12-03 03:00:20 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import os
|
2013-01-04 17:56:26 +01:00
|
|
|
import sys
|
2015-02-02 19:31:16 +01:00
|
|
|
from nose.tools import eq_
|
2013-06-03 04:28:24 +02:00
|
|
|
from utilities import execution_path, run_all
|
2011-12-03 03:00:20 +01:00
|
|
|
import mapnik
|
|
|
|
|
|
|
|
def setup():
|
|
|
|
os.chdir(execution_path('.'))
|
|
|
|
|
2013-01-04 20:28:00 +01:00
|
|
|
def test_parameter_null():
|
|
|
|
p = mapnik.Parameter('key',None)
|
|
|
|
eq_(p[0],'key')
|
|
|
|
eq_(p[1],None)
|
|
|
|
|
|
|
|
def test_parameter_string():
|
2011-12-03 03:00:20 +01:00
|
|
|
p = mapnik.Parameter('key','value')
|
|
|
|
eq_(p[0],'key')
|
|
|
|
eq_(p[1],'value')
|
|
|
|
|
2013-01-17 16:31:27 +01:00
|
|
|
def test_parameter_unicode():
|
|
|
|
p = mapnik.Parameter('key',u'value')
|
|
|
|
eq_(p[0],'key')
|
|
|
|
eq_(p[1],u'value')
|
|
|
|
|
2013-01-04 20:28:00 +01:00
|
|
|
def test_parameter_integer():
|
2013-01-04 17:56:26 +01:00
|
|
|
p = mapnik.Parameter('int',sys.maxint)
|
2011-12-03 03:00:20 +01:00
|
|
|
eq_(p[0],'int')
|
2013-01-04 17:56:26 +01:00
|
|
|
eq_(p[1],sys.maxint)
|
2011-12-03 03:00:20 +01:00
|
|
|
|
2013-01-04 20:28:00 +01:00
|
|
|
def test_parameter_double():
|
|
|
|
p = mapnik.Parameter('double',float(sys.maxint))
|
|
|
|
eq_(p[0],'double')
|
2013-01-04 17:56:26 +01:00
|
|
|
eq_(p[1],float(sys.maxint))
|
2011-12-03 03:00:20 +01:00
|
|
|
|
2013-01-04 20:28:00 +01:00
|
|
|
def test_parameter_boolean():
|
|
|
|
p = mapnik.Parameter('boolean',True)
|
|
|
|
eq_(p[0],'boolean')
|
|
|
|
eq_(p[1],True)
|
2012-03-24 04:04:42 +01:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
setup()
|
2014-07-14 18:34:20 +02:00
|
|
|
exit(run_all(eval(x) for x in dir() if x.startswith("test_")))
|