2009-04-15 23:06:18 +00:00
|
|
|
#!/usr/bin/env python
|
2007-09-25 21:06:52 +00:00
|
|
|
|
2009-04-12 22:38:46 +00:00
|
|
|
from nose.tools import *
|
|
|
|
from utilities import execution_path
|
2007-09-25 21:06:52 +00:00
|
|
|
|
2010-03-11 18:12:22 +00:00
|
|
|
import os, sys, glob, mapnik2
|
2007-09-25 21:06:52 +00:00
|
|
|
|
2009-04-12 22:38:46 +00: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('.'))
|
2007-09-25 21:06:52 +00:00
|
|
|
|
2009-04-12 22:38:46 +00:00
|
|
|
def test():
|
|
|
|
# TODO: Write a better test
|
|
|
|
# 1. Construct map in memory
|
|
|
|
# 2. Save map as XML
|
|
|
|
# 3. Load map to a second object
|
|
|
|
# 4. Compare both map objects
|
2010-03-11 18:12:22 +00:00
|
|
|
map = mapnik2.Map(256, 256)
|
2007-09-25 21:06:52 +00:00
|
|
|
in_map = "../data/good_maps/osm-styles.xml"
|
|
|
|
|
2010-03-11 18:12:22 +00:00
|
|
|
mapnik2.load_map(map, in_map)
|
2009-04-12 22:38:46 +00:00
|
|
|
test_map = "test_map.xml"
|
2007-09-25 21:06:52 +00:00
|
|
|
|
2010-03-11 18:12:22 +00:00
|
|
|
mapnik2.save_map(map, test_map)
|
|
|
|
new_map = mapnik2.Map(256, 256)
|
2007-09-25 21:06:52 +00:00
|
|
|
|
2010-03-11 18:12:22 +00:00
|
|
|
mapnik2.load_map(new_map, test_map)
|
2007-09-25 21:06:52 +00:00
|
|
|
|
2010-03-11 18:12:22 +00:00
|
|
|
eq_(open(test_map).read(),mapnik2.save_map_to_string(new_map))
|
2009-07-24 06:15:58 +00:00
|
|
|
|
2009-04-12 22:38:46 +00:00
|
|
|
if os.path.exists(test_map):
|
|
|
|
os.remove(test_map)
|
2007-09-25 21:06:52 +00:00
|
|
|
else:
|
2009-04-12 22:38:46 +00:00
|
|
|
# Fail, the map wasn't written
|
|
|
|
return False
|