2009-04-16 01:06:18 +02:00
|
|
|
#!/usr/bin/env python
|
2007-09-25 23:06:52 +02:00
|
|
|
|
2009-04-13 00:38:46 +02:00
|
|
|
from nose.tools import *
|
|
|
|
from utilities import execution_path
|
2007-09-25 23:06:52 +02:00
|
|
|
|
2009-04-15 23:42:25 +02:00
|
|
|
import os, sys, glob, mapnik
|
2007-09-25 23:06:52 +02:00
|
|
|
|
2009-04-13 00:38:46 +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('.'))
|
2007-09-25 23:06:52 +02:00
|
|
|
|
2009-04-13 00:38:46 +02: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
|
2009-04-15 23:42:25 +02:00
|
|
|
map = mapnik.Map(256, 256)
|
2007-09-25 23:06:52 +02:00
|
|
|
in_map = "../data/good_maps/osm-styles.xml"
|
|
|
|
|
2009-04-13 00:38:46 +02:00
|
|
|
print "Loading map '%s' ... " % in_map
|
2007-09-25 23:06:52 +02:00
|
|
|
|
2009-04-15 23:42:25 +02:00
|
|
|
mapnik.load_map(map, in_map)
|
2009-04-13 00:38:46 +02:00
|
|
|
test_map = "test_map.xml"
|
2007-09-25 23:06:52 +02:00
|
|
|
|
2009-04-13 00:38:46 +02:00
|
|
|
print "Saving map '%s' ... " % test_map
|
2007-09-25 23:06:52 +02:00
|
|
|
|
2009-04-15 23:42:25 +02:00
|
|
|
mapnik.save_map(map, test_map)
|
|
|
|
new_map = mapnik.Map(256, 256)
|
2007-09-25 23:06:52 +02:00
|
|
|
|
2009-04-13 00:38:46 +02:00
|
|
|
print "Reloading map '%s' ... " % test_map
|
2007-09-25 23:06:52 +02:00
|
|
|
|
2009-04-15 23:42:25 +02:00
|
|
|
mapnik.load_map(new_map, test_map)
|
2007-09-25 23:06:52 +02:00
|
|
|
|
2009-04-13 00:38:46 +02:00
|
|
|
if os.path.exists(test_map):
|
|
|
|
print "Removing '%s'" % test_map
|
|
|
|
os.remove(test_map)
|
2007-09-25 23:06:52 +02:00
|
|
|
else:
|
2009-04-13 00:38:46 +02:00
|
|
|
# Fail, the map wasn't written
|
|
|
|
return False
|