Skip to content
Permalink
Browse files

Update labeling unit tests control image and PAL_SUITE test suite gen…

…eration
  • Loading branch information
dakcarto committed Feb 22, 2014
1 parent 0a9b857 commit 295854ad48aea3638dc37331dab8ac7eed45badb
@@ -210,7 +210,10 @@ def settingsDict(lyr):
return res

def saveContolImage(self, tmpimg=''):
if 'PAL_CONTROL_IMAGE' not in os.environ:
# don't save control images for RenderVsOtherOutput (Vs) tests, since
# those control images belong to a different test result
if ('PAL_CONTROL_IMAGE' not in os.environ
or 'Vs' in self._TestGroup):
return
testgrpdir = 'expected_' + self._TestGroupPrefix
testdir = os.path.join(self._TestDataDir, 'control_images',
@@ -228,6 +231,10 @@ def saveContolImage(self, tmpimg=''):
else:
self._Map.render()
self._Canvas.saveAsImage(imgpath)
# delete extraneous world file (always generated)
wrld_file = imgbasepath + '.PNGw'
if os.path.exists(wrld_file):
os.remove(wrld_file)

def renderCheck(self, mismatch=0, imgpath='', grpprefix=''):
"""Check rendered map canvas or existing image against control image
@@ -331,8 +338,12 @@ def runSuite(module, tests):
"""This allows for a list of test names to be selectively run.
Also, ensures unittest verbose output comes at end, after debug output"""
loader = unittest.defaultTestLoader
if 'PAL_SUITE' in os.environ and tests:
suite = loader.loadTestsFromNames(tests, module)
if 'PAL_SUITE' in os.environ:
if tests:
suite = loader.loadTestsFromNames(tests, module)
else:
raise Exception(
"\n\n####__ 'PAL_SUITE' set, but no tests specified __####\n")
else:
suite = loader.loadTestsFromModule(module)
verb = 2 if 'PAL_VERBOSE' in os.environ else 0
@@ -33,7 +33,10 @@
)

from test_qgspallabeling_base import TestQgsPalLabeling, runSuite
from test_qgspallabeling_tests import TestPointBase
from test_qgspallabeling_tests import (
TestPointBase,
suiteTests
)


class TestCanvasPoint(TestQgsPalLabeling, TestPointBase):
@@ -61,13 +64,9 @@ def checkTest(self, **kwargs):

if __name__ == '__main__':
# NOTE: unless PAL_SUITE env var is set all test class methods will be run
# ex: 'TestGroup(Point|Line|Curved|Polygon|Feature).test_method'
suite = [
'TestCanvasPoint.test_default_label',
'TestCanvasPoint.test_text_size_map_unit',
'TestCanvasPoint.test_text_color',
'TestCanvasPoint.test_partials_labels_enabled',
'TestCanvasPoint.test_partials_labels_disabled',
]
# SEE: test_qgspallabeling_tests.suiteTests() to define suite
suite = (
['TestCanvasPoint.' + t for t in suiteTests()['sp_suite']]
)
res = runSuite(sys.modules[__name__], suite)
sys.exit(not res.wasSuccessful())
@@ -34,7 +34,10 @@
)

from test_qgspallabeling_base import TestQgsPalLabeling, runSuite
from test_qgspallabeling_tests import TestPointBase
from test_qgspallabeling_tests import (
TestPointBase,
suiteTests
)


# noinspection PyShadowingNames
@@ -152,19 +155,10 @@ def setUp(self):

if __name__ == '__main__':
# NOTE: unless PAL_SUITE env var is set all test class methods will be run
# ex: 'TestGroup(Point|Line|Curved|Polygon|Feature).test_method'
suite = [
'TestComposerPoint.test_default_label',
'TestComposerPoint.test_text_size_map_unit',
'TestComposerPoint.test_text_color',
'TestComposerPoint.test_partials_labels_enabled',
'TestComposerPoint.test_partials_labels_disabled',

'TestComposerVsCanvasPoint.test_default_label',
'TestComposerVsCanvasPoint.test_text_size_map_unit',
'TestComposerVsCanvasPoint.test_text_color',
'TestComposerVsCanvasPoint.test_partials_labels_enabled',
'TestComposerVsCanvasPoint.test_partials_labels_disabled',
]
# SEE: test_qgspallabeling_tests.suiteTests() to define suite
suite = (
['TestComposerPoint.' + t for t in suiteTests()['sp_suite']] +
['TestComposerVsCanvasPoint.' + t for t in suiteTests()['sp_vs_suite']]
)
res = runSuite(sys.modules[__name__], suite)
sys.exit(not res.wasSuccessful())
@@ -8,6 +8,8 @@
PAL_CONTROL_IMAGE to trigger building of new control images
PAL_REPORT to open any failed image check reports in web browser
PAL_SERVER_TEMP to open the web server temp directory, instead of deleting
.. note:: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -44,7 +46,10 @@
)

from test_qgspallabeling_base import TestQgsPalLabeling, runSuite
from test_qgspallabeling_tests import TestPointBase
from test_qgspallabeling_tests import (
TestPointBase,
suiteTests
)

MAPSERV = getLocalServer()

@@ -83,9 +88,8 @@ def tearDownClass(cls):
TestQgsPalLabeling.tearDownClass()
# layers removed, save empty project file
cls._TestProj.write()
if "PAL_REPORT" in os.environ:
if "PAL_SERVER_TEMP" in os.environ:
MAPSERV.stop_processes()
# MAPSERV.fcgi_server_process().stop()
MAPSERV.open_temp_dir()
else:
MAPSERV.shutdown()
@@ -173,21 +177,10 @@ def setUpClass(cls):

if __name__ == '__main__':
# NOTE: unless PAL_SUITE env var is set all test class methods will be run
# ex: 'TestGroup(Point|Line|Curved|Polygon|Feature).test_method'
suite = [
'TestServerPoint.test_default_label',
'TestServerPoint.test_text_size_map_unit',
'TestServerPoint.test_text_color',
'TestServerPoint.test_partials_labels_enabled',
'TestServerPoint.test_partials_labels_disabled',

'TestServerVsCanvasPoint.test_default_label',
'TestServerVsCanvasPoint.test_text_size_map_unit',
'TestServerVsCanvasPoint.test_text_color',
'TestServerVsCanvasPoint.test_partials_labels_enabled',
'TestServerVsCanvasPoint.test_partials_labels_disabled',
]
# SEE: test_qgspallabeling_tests.suiteTests() to define suite
suite = (
['TestServerPoint.' + t for t in suiteTests()['sp_suite']] +
['TestServerVsCanvasPoint.' + t for t in suiteTests()['sp_vs_suite']]
)
res = runSuite(sys.modules[__name__], suite)
# if SPAWN:
# os.remove(TESTPROJDIR) # remove temp directory (why does this error?)
sys.exit(not res.wasSuccessful())
@@ -142,5 +142,24 @@ def test_partials_labels_disabled(self):
self.checkTest()


# noinspection PyPep8Naming
def suiteTests():
"""
Use to define which tests are run when PAL_SUITE is set.
Use sp_vs_suite comparison of server and composer outputs to canvas
"""
return {
'sp_suite': [
# 'test_background_svg',
'test_background_svg_w_offset',
],
'sp_vs_suite': [
# 'test_background_svg',
'test_background_svg_w_offset',
# 'test_background_rect_w_offset',
]
}


if __name__ == '__main__':
pass

0 comments on commit 295854a

Please sign in to comment.
You can’t perform that action at this time.