2012-05-25 01:39:24 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from nose.tools import *
|
|
|
|
from utilities import execution_path
|
|
|
|
|
|
|
|
import os, mapnik
|
|
|
|
|
|
|
|
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('.'))
|
|
|
|
|
2012-09-05 13:53:37 +02:00
|
|
|
if 'gdal' in mapnik.DatasourceCache.plugin_names():
|
2012-05-25 01:39:24 +02:00
|
|
|
|
2012-08-16 04:22:47 +02:00
|
|
|
def test_map_alpha_compare():
|
|
|
|
m = mapnik.Map(600,400)
|
|
|
|
mapnik.load_map(m,'../data/good_maps/raster-alpha.xml')
|
|
|
|
m.zoom_all()
|
|
|
|
actual = '/tmp/mapnik-raster-alpha.png'
|
|
|
|
expected = 'images/support/raster-alpha.png'
|
|
|
|
im = mapnik.Image(m.width,m.height)
|
|
|
|
mapnik.render(m,im)
|
|
|
|
im.save(actual)
|
|
|
|
expected_im = mapnik.Image.open(expected)
|
|
|
|
eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected))
|
2012-09-05 13:53:37 +02:00
|
|
|
|
2012-08-16 04:22:47 +02:00
|
|
|
def test_map_alpha_gradient_compare():
|
|
|
|
m = mapnik.Map(600,400)
|
|
|
|
mapnik.load_map(m,'../data/good_maps/raster-alpha-gradient.xml')
|
|
|
|
m.zoom_all()
|
|
|
|
actual = '/tmp/mapnik-raster-alpha-gradient.png'
|
|
|
|
expected = 'images/support/raster-alpha-gradient.png'
|
|
|
|
im = mapnik.Image(m.width,m.height)
|
|
|
|
mapnik.render(m,im)
|
|
|
|
im.save(actual)
|
|
|
|
expected_im = mapnik.Image.open(expected)
|
|
|
|
eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected))
|
2012-07-25 22:16:46 +02:00
|
|
|
|
2012-05-25 01:39:24 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
setup()
|
|
|
|
[eval(run)() for run in dir() if 'test_' in run]
|