2009-07-28 08:27:10 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import os
|
2011-11-23 12:33:58 +01:00
|
|
|
import mapnik
|
2009-07-28 08:27:10 +02:00
|
|
|
from nose.tools import *
|
2011-12-22 21:41:51 +01:00
|
|
|
from utilities import execution_path
|
2009-07-28 08:27:10 +02:00
|
|
|
|
|
|
|
def setup():
|
|
|
|
# All of the paths used are relative, if we run the tests
|
|
|
|
# from another directory we need to chdir()
|
|
|
|
os.chdir(execution_path('.'))
|
|
|
|
|
|
|
|
def _pycairo_surface(type,sym):
|
2011-11-23 12:33:58 +01:00
|
|
|
if mapnik.has_pycairo():
|
2009-07-28 08:27:10 +02:00
|
|
|
import cairo
|
|
|
|
test_cairo_file = 'test.%s' % type
|
2011-11-23 12:33:58 +01:00
|
|
|
m = mapnik.Map(256,256)
|
|
|
|
mapnik.load_map(m,'../data/good_maps/%s_symbolizer.xml' % sym)
|
2009-07-28 08:27:10 +02:00
|
|
|
surface = getattr(cairo,'%sSurface' % type.upper())(test_cairo_file, m.width,m.height)
|
2011-11-23 12:33:58 +01:00
|
|
|
mapnik.render(m, surface)
|
2009-07-28 08:27:10 +02:00
|
|
|
surface.finish()
|
2012-02-24 22:13:56 +01:00
|
|
|
|
2009-07-28 08:27:10 +02:00
|
|
|
if os.path.exists(test_cairo_file):
|
|
|
|
os.remove(test_cairo_file)
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
# Fail, the file wasn't written
|
|
|
|
return False
|
|
|
|
|
|
|
|
def test_pycairo_svg_surface():
|
|
|
|
return _pycairo_surface('svg','point')
|
|
|
|
|
|
|
|
def test_pycairo_svg_surface():
|
|
|
|
return _pycairo_surface('svg','building')
|
2012-02-24 22:13:56 +01:00
|
|
|
|
2009-07-28 08:27:10 +02:00
|
|
|
def test_pycairo_svg_surface():
|
|
|
|
return _pycairo_surface('svg','polygon')
|
|
|
|
|
|
|
|
def test_pycairo_svg_surface():
|
|
|
|
return _pycairo_surface('pdf','point')
|
|
|
|
|
|
|
|
def test_pycairo_svg_surface():
|
|
|
|
return _pycairo_surface('pdf','building')
|
2012-02-24 22:13:56 +01:00
|
|
|
|
2009-07-28 08:27:10 +02:00
|
|
|
def test_pycairo_svg_surface():
|
|
|
|
return _pycairo_surface('pdf','polygon')
|
|
|
|
|
|
|
|
def test_pycairo_svg_surface():
|
|
|
|
return _pycairo_surface('ps','point')
|
|
|
|
|
|
|
|
def test_pycairo_svg_surface():
|
|
|
|
return _pycairo_surface('ps','building')
|
2012-02-24 22:13:56 +01:00
|
|
|
|
2009-07-28 08:27:10 +02:00
|
|
|
def test_pycairo_svg_surface():
|
|
|
|
return _pycairo_surface('ps','polygon')
|
2011-08-31 00:51:42 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
setup()
|
|
|
|
[eval(run)() for run in dir() if 'test_' in run]
|