From dc889d60c52841858350ee854dc99bb2f33c229c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 9 Feb 2012 06:23:20 +0100 Subject: Extensions. Unit tests improvement. (bzr r10953) --- share/extensions/test/dxf_outlines.test.py | 36 +++-- share/extensions/test/gimp_xcf.test.py | 58 ++++++-- share/extensions/test/inkex.test.py | 38 ++++++ share/extensions/test/markers_strokepaint.test.py | 44 ++++-- share/extensions/test/perspective.test.py | 35 +++-- share/extensions/test/printing-marks.test.py | 26 ---- share/extensions/test/printing_marks.test.py | 26 ++++ share/extensions/test/summersnight.test.py | 35 +++-- share/extensions/test/svg/default-inkscape-SVG.svg | 37 +++++ share/extensions/test/svg/default-plain-SVG.svg | 29 ++++ share/extensions/test/svg/empty-SVG.svg | 13 ++ share/extensions/test/svg/multilayered-test.svg | 152 +++++++++++++++++++++ .../test/svg_and_media_zip_output.test.py | 4 +- 13 files changed, 430 insertions(+), 103 deletions(-) create mode 100755 share/extensions/test/inkex.test.py delete mode 100755 share/extensions/test/printing-marks.test.py create mode 100755 share/extensions/test/printing_marks.test.py create mode 100644 share/extensions/test/svg/default-inkscape-SVG.svg create mode 100644 share/extensions/test/svg/default-plain-SVG.svg create mode 100644 share/extensions/test/svg/empty-SVG.svg create mode 100644 share/extensions/test/svg/multilayered-test.svg diff --git a/share/extensions/test/dxf_outlines.test.py b/share/extensions/test/dxf_outlines.test.py index 5124c5306..e3b64e1cd 100755 --- a/share/extensions/test/dxf_outlines.test.py +++ b/share/extensions/test/dxf_outlines.test.py @@ -1,26 +1,32 @@ #!/usr/bin/env python +''' +Unit test file for ../dxf_outlines.py +Revision history: + * 2012-01-25 (jazzynico): first working version (only checks the extension + with the default parameters). -# This is only the automatic generated test file for ../dxf_outlines.py -# This must be filled with real tests and this commentary -# must be cleared. -# If you want to help, read the python unittest documentation: -# http://docs.python.org/library/unittest.html +-- +If you want to help, read the python unittest documentation: +http://docs.python.org/library/unittest.html +''' import sys -sys.path.append('..') # this line allows to import the extension code - import unittest + +sys.path.append('..') # this line allows to import the extension code from dxf_outlines import * -class MyEffectBasicTest(unittest.TestCase): +class DFXOutlineBasicTest(unittest.TestCase): + #def setUp(self): - #def setUp(self): + def test_run_without_parameters(self): + args = [ 'minimal-blank.svg' ] + e = MyEffect() + e.affect(args, False) - def test_run_without_parameters(self): - args = [ 'minimal-blank.svg' ] - e = MyEffect() - e.affect( args, False ) - #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) if __name__ == '__main__': - unittest.main() + unittest.main() + #suite = unittest.TestLoader().loadTestsFromTestCase(DFXOutlineBasicTest) + #unittest.TextTestRunner(verbosity=2).run(suite) + diff --git a/share/extensions/test/gimp_xcf.test.py b/share/extensions/test/gimp_xcf.test.py index ae238f0cf..b5a530a49 100755 --- a/share/extensions/test/gimp_xcf.test.py +++ b/share/extensions/test/gimp_xcf.test.py @@ -1,26 +1,54 @@ #!/usr/bin/env python +''' +Unit test file for ../gimp_xcf.py +Revision history: + * 2012-01-26 (jazzynico): checks defaulf parameters and file handling. -# This is only the automatic generated test file for ../gimp_xcf.py -# This must be filled with real tests and this commentary -# must be cleared. -# If you want to help, read the python unittest documentation: -# http://docs.python.org/library/unittest.html +-- +If you want to help, read the python unittest documentation: +http://docs.python.org/library/unittest.html +''' +import os import sys -sys.path.append('..') # this line allows to import the extension code - import unittest + +sys.path.append('..') # this line allows to import the extension code from gimp_xcf import * -class MyEffectBasicTest(unittest.TestCase): +class GimpXCFBasicTest(unittest.TestCase): + def setUp(self): + sys.stdout = open(os.devnull, 'w') + + def test_expected_file(self): + # multilayered-test.svg provides 3 layers and a sublayer + # (all non empty). + args = [ 'svg/multilayered-test.svg' ] + e = MyEffect() + e.affect(args, False) + #self.assertRaises(GimpXCFExpectedIOError, e.affect, args, False) + + def test_empty_file(self): + # empty-SVG.svg contains an emply svg element (no layer, no object). + # The file must have at least one non empty layer and thus the + # extension rejects it and send an error message. + args = [ 'svg/empty-SVG.svg' ] + e = MyEffect() + e.affect(args, False) + self.assertEqual(e.valid, 0) - #def setUp(self): + def test_empty_layer_file(self): + # default-inkscape-SVG.svg is a copy of the defaut Inkscape + # template, with one empty layer. + # The file must have at least one non empty layer and thus the + # extension rejects it and send an error message. + args = [ 'svg/default-inkscape-SVG.svg' ] + e = MyEffect() + e.affect(args, False) + self.assertEqual(e.valid, 0) - def test_run_without_parameters(self): - args = [ 'minimal-blank.svg' ] - e = MyEffect() - e.affect( args, False ) - #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) if __name__ == '__main__': - unittest.main() + #unittest.main() + suite = unittest.TestLoader().loadTestsFromTestCase(GimpXCFBasicTest) + unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/share/extensions/test/inkex.test.py b/share/extensions/test/inkex.test.py new file mode 100755 index 000000000..ed2256ae7 --- /dev/null +++ b/share/extensions/test/inkex.test.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +''' +Unit test file for ../inkex.py +Revision history: + * 2012-01-27 (jazzynico): check errormsg function. + +-- +If you want to help, read the python unittest documentation: +http://docs.python.org/library/unittest.html +''' + +import sys +sys.path.append('..') # this line allows to import the extension code + +import unittest +from inkex import errormsg + +class InkexBasicTest(unittest.TestCase): + + #def setUp(self): + + def test_ascii(self): + #Parse ABCabc + errormsg('ABCabc') + + def test_nonunicode_latin1(self): + #Parse Àûïàèé + errormsg('Àûïàèé') + + def test_unicode_latin1(self): + #Parse Àûïàèé (unicode) + errormsg(u'Àûïàèé') + +if __name__ == '__main__': + #unittest.main() + suite = unittest.TestLoader().loadTestsFromTestCase(InkexBasicTest) + unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/share/extensions/test/markers_strokepaint.test.py b/share/extensions/test/markers_strokepaint.test.py index 8c1262b75..386166bce 100755 --- a/share/extensions/test/markers_strokepaint.test.py +++ b/share/extensions/test/markers_strokepaint.test.py @@ -1,26 +1,40 @@ #!/usr/bin/env python +''' +Unit test file for ../markers_strokepaint.py +Revision history: + * 2012-01-27 (jazzynico): checks defaulf parameters and file handling. -# This is only the automatic generated test file for ../markers_strokepaint.py -# This must be filled with real tests and this commentary -# must be cleared. -# If you want to help, read the python unittest documentation: -# http://docs.python.org/library/unittest.html +-- +If you want to help, read the python unittest documentation: +http://docs.python.org/library/unittest.html +''' import sys -sys.path.append('..') # this line allows to import the extension code - import unittest + +sys.path.append('..') # this line allows to import the extension code from markers_strokepaint import * -class MyEffectBasicTest(unittest.TestCase): +class StrokeColorBasicTest(unittest.TestCase): + + #def setUp(self): - #def setUp(self): + def test_no_defs(self): + args = ['svg/empty-SVG.svg'] + e = MyEffect() + e.affect(args, False) + #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) - def test_run_without_parameters(self): - args = [ 'minimal-blank.svg' ] - e = MyEffect() - e.affect( args, False ) - #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) + def test_empty_defs(self): + args = ['svg/default-plain-SVG.svg'] + e = MyEffect() + e.affect(args, False) +''' + def test_markers(self): + args = ['svg/markers.svg'] +''' if __name__ == '__main__': - unittest.main() + #unittest.main() + suite = unittest.TestLoader().loadTestsFromTestCase(StrokeColorBasicTest) + unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/share/extensions/test/perspective.test.py b/share/extensions/test/perspective.test.py index 3d4daf540..a10297507 100755 --- a/share/extensions/test/perspective.test.py +++ b/share/extensions/test/perspective.test.py @@ -1,26 +1,31 @@ #!/usr/bin/env python +''' +Unit test file for ../perspective.py +Revision history: + * 2012-01-28 (jazzynico): first working version (only checks the extension + with the default parameters). -# This is only the automatic generated test file for ../perspective.py -# This must be filled with real tests and this commentary -# must be cleared. -# If you want to help, read the python unittest documentation: -# http://docs.python.org/library/unittest.html +-- +If you want to help, read the python unittest documentation: +http://docs.python.org/library/unittest.html +''' import sys -sys.path.append('..') # this line allows to import the extension code - import unittest + +sys.path.append('..') # this line allows to import the extension code from perspective import * -class ProjectBasicTest(unittest.TestCase): +class PerspectiveBasicTest(unittest.TestCase): - #def setUp(self): + #def setUp(self): - def test_run_without_parameters(self): - args = [ 'minimal-blank.svg' ] - e = Project() - e.affect( args, False ) - #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) + def test_run_without_parameters(self): + args = ['minimal-blank.svg'] + e = Project() + self.assertRaises(SystemExit, e.affect, args) if __name__ == '__main__': - unittest.main() + unittest.main() + #suite = unittest.TestLoader().loadTestsFromTestCase(PerspectiveBasicTest) + #unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/share/extensions/test/printing-marks.test.py b/share/extensions/test/printing-marks.test.py deleted file mode 100755 index 0438e327c..000000000 --- a/share/extensions/test/printing-marks.test.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python - -# This is only the automatic generated test file for ../printing-marks.py -# This must be filled with real tests and this commentary -# must be cleared. -# If you want to help, read the python unittest documentation: -# http://docs.python.org/library/unittest.html - -import sys -sys.path.append('..') # this line allows to import the extension code - -import unittest -from printing-marks import * - -class Printing_MarksBasicTest(unittest.TestCase): - - #def setUp(self): - - def test_run_without_parameters(self): - args = [ 'minimal-blank.svg' ] - e = Printing_Marks() - e.affect( args, False ) - #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) - -if __name__ == '__main__': - unittest.main() diff --git a/share/extensions/test/printing_marks.test.py b/share/extensions/test/printing_marks.test.py new file mode 100755 index 000000000..8e4bcc31c --- /dev/null +++ b/share/extensions/test/printing_marks.test.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# This is only the automatic generated test file for ../printing-marks.py +# This must be filled with real tests and this commentary +# must be cleared. +# If you want to help, read the python unittest documentation: +# http://docs.python.org/library/unittest.html + +import sys +sys.path.append('..') # this line allows to import the extension code + +import unittest +from printing_marks import * + +class PrintingMarksBasicTest(unittest.TestCase): + + #def setUp(self): + + def test_run_without_parameters(self): + args = [ 'minimal-blank.svg' ] + e = Printing_Marks() + e.affect( args, False ) + #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) + +if __name__ == '__main__': + unittest.main() diff --git a/share/extensions/test/summersnight.test.py b/share/extensions/test/summersnight.test.py index e8e2733b8..711bd051d 100755 --- a/share/extensions/test/summersnight.test.py +++ b/share/extensions/test/summersnight.test.py @@ -1,26 +1,31 @@ #!/usr/bin/env python +''' +Unit test file for ../summersnight.py +Revision history: + * 2012-01-28 (jazzynico): first working version (only checks the extension + with the default parameters). -# This is only the automatic generated test file for ../summersnight.py -# This must be filled with real tests and this commentary -# must be cleared. -# If you want to help, read the python unittest documentation: -# http://docs.python.org/library/unittest.html +-- +If you want to help, read the python unittest documentation: +http://docs.python.org/library/unittest.html +''' import sys -sys.path.append('..') # this line allows to import the extension code - import unittest + +sys.path.append('..') # this line allows to import the extension code from summersnight import * -class ProjectBasicTest(unittest.TestCase): +class EnvelopeBasicTest(unittest.TestCase): - #def setUp(self): + #def setUp(self): - def test_run_without_parameters(self): - args = [ 'minimal-blank.svg' ] - e = Project() - e.affect( args, False ) - #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) + def test_run_without_parameters(self): + args = ['minimal-blank.svg'] + e = Project() + self.assertRaises(SystemExit, e.affect, args) if __name__ == '__main__': - unittest.main() + unittest.main() + #suite = unittest.TestLoader().loadTestsFromTestCase(EnvelopeBasicTest) + #unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/share/extensions/test/svg/default-inkscape-SVG.svg b/share/extensions/test/svg/default-inkscape-SVG.svg new file mode 100644 index 000000000..a6a610fdb --- /dev/null +++ b/share/extensions/test/svg/default-inkscape-SVG.svg @@ -0,0 +1,37 @@ + + + + + + + + + image/svg+xml + + + + + + diff --git a/share/extensions/test/svg/default-plain-SVG.svg b/share/extensions/test/svg/default-plain-SVG.svg new file mode 100644 index 000000000..544273366 --- /dev/null +++ b/share/extensions/test/svg/default-plain-SVG.svg @@ -0,0 +1,29 @@ + + + + + + + + + image/svg+xml + + + + + + + diff --git a/share/extensions/test/svg/empty-SVG.svg b/share/extensions/test/svg/empty-SVG.svg new file mode 100644 index 000000000..475cc856b --- /dev/null +++ b/share/extensions/test/svg/empty-SVG.svg @@ -0,0 +1,13 @@ + + + + + diff --git a/share/extensions/test/svg/multilayered-test.svg b/share/extensions/test/svg/multilayered-test.svg new file mode 100644 index 000000000..c3bf929e9 --- /dev/null +++ b/share/extensions/test/svg/multilayered-test.svg @@ -0,0 +1,152 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + Bottom layer + + + + + + Middle sublayer + + + + Middle layer + + + + Top layer + + + diff --git a/share/extensions/test/svg_and_media_zip_output.test.py b/share/extensions/test/svg_and_media_zip_output.test.py index 42610f0af..7f68dd6ef 100755 --- a/share/extensions/test/svg_and_media_zip_output.test.py +++ b/share/extensions/test/svg_and_media_zip_output.test.py @@ -18,10 +18,10 @@ class SVG_and_Media_ZIP_Output_BasicTest(unittest.TestCase): def test_run_without_parameters(self): args = [ 'minimal-blank.svg' ] - e = SVG_and_Media_ZIP_Output() + e = CompressedMediaOutput() e.affect( args, False ) #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) - e.clear_tmp() + #e.clear_tmp() if __name__ == '__main__': unittest.main() -- cgit v1.2.3