@@ -41,6 +41,13 @@ def setUp(self):
41
41
pass
42
42
self .server = QgsServer ()
43
43
44
+ def assert_headers (self , header , body ):
45
+ headers = Message (StringIO (header ))
46
+ if 'content-length' in headers :
47
+ content_length = int (headers ['content-length' ])
48
+ body_length = len (body )
49
+ self .assertEqual (content_length , body_length , msg = "Header reported content-length: %d Actual body length was: %d" % (content_length , body_length ))
50
+
44
51
def test_destructor_segfaults (self ):
45
52
"""Segfault on destructor?"""
46
53
server = QgsServer ()
@@ -294,20 +301,29 @@ def test_getfeature(self):
294
301
for id , req in tests :
295
302
self .wfs_getfeature_compare (id , req )
296
303
297
- def assert_headers (self , header , body ):
298
- headers = Message (StringIO (header ))
299
- if 'content-length' in headers :
300
- content_length = int (headers ['content-length' ])
301
- body_length = len (body )
302
- self .assertEqual (content_length , body_length , msg = "Header reported content-length: %d Actual body length was: %d" % (content_length , body_length ))
304
+ def test_getLegendGraphics (self ):
305
+ """Test that does not return an exception but an image"""
306
+ parms = {
307
+ 'MAP' : self .testdata_path + "test%2Bproject.qgs" ,
308
+ 'SERVICE' : 'WMS' ,
309
+ 'VERSIONE' : '1.0.0' ,
310
+ 'REQUEST' : 'GetLegendGraphic' ,
311
+ 'FORMAT' : 'image/png' ,
312
+ #'WIDTH': '20', # optional
313
+ #'HEIGHT': '20', # optional
314
+ 'LAYER' : u'testlayer+èé' ,
315
+ }
316
+ qs = '&' .join ([u"%s=%s" % (k , v ) for k , v in parms .iteritems ()])
317
+ h , r = self .server .handleRequest (qs )
318
+ self .assertEquals (- 1 , h .find ('Content-Type: text/xml; charset=utf-8' ), "Header: %s\n Response:\n %s" % (h , r ))
319
+ self .assertNotEquals (- 1 , h .find ('Content-Type: image/png' ), "Header: %s\n Response:\n %s" % (h , r ))
320
+
303
321
304
322
# The following code was used to test type conversion in python bindings
305
323
# def test_qpair(self):
306
324
# """Test QPair bindings"""
307
325
# f, s = self.server.testQPair(('First', 'Second'))
308
326
# self.assertEqual(f, 'First')
309
327
# self.assertEqual(s, 'Second')
310
-
311
-
312
328
if __name__ == '__main__' :
313
329
unittest .main ()
0 commit comments