@@ -190,19 +190,6 @@ def __init__(self, kind, exe, fcgi_bin, conf_dir, temp_dir):
190
190
'qgs_mapserv.sock' )
191
191
if self ._mac :
192
192
self .set_startenv ({'QGIS_LOG_FILE' : '{0}/log/qgis_server.log' .format (temp_dir )})
193
- # self.set_startcmd([
194
- # exe, '-n', '-s', fcgi_sock, '--', temp_dir + fcgi_bin, '&'
195
- # ])
196
- # self.set_startcmd([init_scr, 'start', exe, fcgi_sock,
197
- # temp_dir + fcgi_bin, temp_dir])
198
- # self.set_startcmd([
199
- # '/bin/bash', 'exec' 'env', '-i',
200
- # 'QGIS_LOG_FILE=' + temp_dir + '/log/qgis_server.log',
201
- # exe, '-n', '-s', fcgi_sock, '--', temp_dir + fcgi_bin
202
- # ])
203
- # self.set_startcmd([
204
- # '/bin/bash', '-c',
205
- # "'exec env -i QGIS_LOG_FILE={0}/log/qgis_server.log {1} -n -s {2} -- {3}'".format(temp_dir, exe, fcgi_sock, temp_dir + fcgi_bin)])
206
193
init_scr = os .path .join (conf_dir , 'fcgi' , 'scripts' ,
207
194
'spawn_fcgi_mac.sh' )
208
195
self .set_startcmd ([init_scr , 'start' , exe , fcgi_sock ,
@@ -243,7 +230,7 @@ def __init__(self, fcgi_bin):
243
230
self ._web_dir = ''
244
231
245
232
servers = [
246
- ('spawn-fcgi' , 'lighttpd' ),
233
+ ('spawn-fcgi' , 'lighttpd' )
247
234
#('fcgiwrap', 'nginx'),
248
235
#('uwsgi', 'nginx'),
249
236
]
@@ -564,6 +551,10 @@ def getLocalServer():
564
551
565
552
If MAPSERV is already running the handle to it will be returned.
566
553
554
+ Before unit test class add:
555
+
556
+ MAPSERV = getLocalServer()
557
+
567
558
IMPORTANT: When using MAPSERV in a test class, ensure to set these:
568
559
569
560
@classmethod
@@ -576,12 +567,25 @@ def setUpClass(cls):
576
567
def tearDownClass(cls):
577
568
MAPSERV.shutdown()
578
569
# or, when testing, instead of shutdown...
579
- MAPSERV.stop_processes()
580
- MAPSERV.open_temp_dir()
570
+ # MAPSERV.stop_processes()
571
+ # MAPSERV.open_temp_dir()
581
572
582
573
This ensures the subprocesses are stopped and the temp directory is removed.
583
574
If this is not used, the server processes may continue to run after tests.
584
575
576
+ If you need to restart the qgis_mapserv.fcgi spawning process to show
577
+ changes to project settings, consider adding:
578
+
579
+ def setUp(self):
580
+ '''Run before each test.'''
581
+ # web server stays up across all tests
582
+ MAPSERV.fcgi_server_process().start()
583
+
584
+ def tearDown(self):
585
+ '''Run after each test.'''
586
+ # web server stays up across all tests
587
+ MAPSERV.fcgi_server_process().stop()
588
+
585
589
:rtype: QgisLocalServer
586
590
"""
587
591
global SERVRUN # pylint: disable=W0603
@@ -645,13 +649,8 @@ def tearDownClass(cls):
645
649
break
646
650
except urllib2 .URLError :
647
651
pass
648
- # res = None
649
- # try:
650
- # res = urllib2.urlopen(srv.web_url(), timeout=30)
651
- # except urllib2.URLError:
652
- # pass
653
652
msg = 'Web server basic access to root index.html failed'
654
- print repr (res )
653
+ # print repr(res)
655
654
assert (res is not None
656
655
and res .getcode () == 200
657
656
and 'Web Server Working' in res .read ()), msg
0 commit comments