Skip to content
Browse files

Bumped to 2.6.2 with elimination of local dependency on test.shp for …

…unit tests
  • Loading branch information...
1 parent 3bda865 commit ef0c939e19b8a7e7d26948ddda45afb1add69c5a @migurski migurski committed Nov 17, 2012
View
2 cascadenik/__init__.py
@@ -6,7 +6,7 @@
The code:
https://github.com/mapnik/Cascadenik
"""
-__version__ = '2.6.1'
+__version__ = '2.6.2'
from os import mkdir, chmod
from os.path import isdir, realpath, expanduser, dirname, exists
View
40 cascadenik/tests.py
@@ -1876,11 +1876,21 @@ class CompileXMLTests(unittest.TestCase):
def setUp(self):
# a directory for all the temp files to be created below
self.tmpdir = tempfile.mkdtemp(prefix='cascadenik-tests-')
+ self.data = tempfile.mkdtemp(prefix='cascadenik-data-')
self.dirs = Directories(self.tmpdir, self.tmpdir, os.getcwd())
-
+
+ for name in ('test.dbf', 'test.prj', 'test.qpj', 'test.shp', 'test.shx'):
+ href = 'http://cascadenik-sampledata.s3.amazonaws.com/data/' + name
+ path = os.path.join(self.data, name)
+
+ file = open(path, 'w')
+ file.write(urllib.urlopen(href).read())
+ file.close()
+
def tearDown(self):
# destroy the above-created directory
shutil.rmtree(self.tmpdir)
+ shutil.rmtree(self.data)
def testCompile1(self):
"""
@@ -2050,11 +2060,12 @@ def testCompile2(self):
<Layer>
<Datasource base="template">
<Parameter name="type">shape</Parameter>
- <Parameter name="file">data/test.shp</Parameter>
+ <Parameter name="file">%(data)s/test.shp</Parameter>
</Datasource>
</Layer>
</Map>
- """
+ """ % self.__dict__
+
map = compile(s, self.dirs)
mmap = mapnik.Map(640, 480)
@@ -2090,15 +2101,15 @@ def testCompile2(self):
self.assertEqual(len(map_el.find("Layer").findall('Datasource')), 1)
params = dict(((p.get('name'), p.text) for p in map_el.find('Layer').find('Datasource').findall('Parameter')))
self.assertEqual(params['type'], 'shape')
- self.assertEqual(params['file'][-13:], 'data/test.shp')
+ self.assertTrue(params['file'].endswith('%s/test.shp' % self.data))
self.assertEqual(params['encoding'], 'latin1')
def testCompile3(self):
"""
"""
map = output.Map(layers=[
output.Layer('this',
- output.Datasource(type="shape",file="data/test.shp"), [
+ output.Datasource(type="shape",file="%s/test.shp" % self.data), [
output.Style('a style', [
output.Rule(
output.MinScaleDenominator(1),
@@ -2110,7 +2121,7 @@ def testCompile3(self):
])
]),
output.Layer('that',
- output.Datasource(type="shape",file="data/test.shp"), [
+ output.Datasource(type="shape",file="%s/test.shp" % self.data), [
output.Style('another style', [
output.Rule(
output.MinScaleDenominator(101),
@@ -2218,11 +2229,12 @@ def testCompile4(self):
<Layer>
<Datasource base="template">
<Parameter name="type">shape</Parameter>
- <Parameter name="file">data/test.shp</Parameter>
+ <Parameter name="file">%(data)s/test.shp</Parameter>
</Datasource>
</Layer>
</Map>
- """
+ """ % self.__dict__
+
mmap = mapnik.Map(640, 480)
ms = compile(s, self.dirs)
ms.to_mapnik(mmap, self.dirs)
@@ -2237,11 +2249,12 @@ def testCompile5(self):
<Layer>
<Datasource>
<Parameter name="type">shape</Parameter>
- <Parameter name="file">data/test.shp</Parameter>
+ <Parameter name="file">%(data)s/test.shp</Parameter>
</Datasource>
</Layer>
</Map>
- """.encode('utf-8')
+ """.encode('utf-8') % self.__dict__
+
mmap = mapnik.Map(640, 480)
ms = compile(s, self.dirs)
ms.to_mapnik(mmap, self.dirs)
@@ -2430,11 +2443,12 @@ def testCompile10(self):
<Layer>
<Datasource base="template">
<Parameter name="type">shape</Parameter>
- <Parameter name="file">data/test.shp</Parameter>
+ <Parameter name="file">%(data)s/test.shp</Parameter>
</Datasource>
</Layer>
</Map>
- """
+ """ % self.__dict__
+
map = compile(s, self.dirs)
mmap = mapnik.Map(640, 480)
@@ -2450,7 +2464,7 @@ def testCompile10(self):
self.assertEqual(len(map_el.find("Layer").findall('Datasource')), 1)
params = dict(((p.get('name'), p.text) for p in map_el.find('Layer').find('Datasource').findall('Parameter')))
self.assertEqual(params['type'], 'shape')
- self.assertEqual(params['file'][-13:], 'data/test.shp')
+ self.assertTrue(params['file'].endswith('%s/test.shp' % self.data))
self.assertEqual(params['encoding'], 'latin1')
if MAPNIK_VERSION < 200100:
View
BIN data/test.dbf
Binary file not shown.
View
1 data/test.prj
@@ -1 +0,0 @@
-GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
View
1 data/test.qpj
@@ -1 +0,0 @@
-GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]]
View
BIN data/test.shp
Binary file not shown.
View
BIN data/test.shx
Binary file not shown.

0 comments on commit ef0c939

Please sign in to comment.
Something went wrong with that request. Please try again.