#!/usr/bin/env python from nose.tools import * from utilities import execution_path import os, sys, glob, mapnik2 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 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 map = mapnik2.Map(256, 256) in_map = "../data/good_maps/osm-styles.xml" mapnik2.load_map(map, in_map) test_map = "test_map.xml" mapnik2.save_map(map, test_map) new_map = mapnik2.Map(256, 256) mapnik2.load_map(new_map, test_map) eq_(open(test_map).read(),mapnik2.save_map_to_string(new_map)) if os.path.exists(test_map): os.remove(test_map) else: # Fail, the map wasn't written return False