summaryrefslogtreecommitdiffstats
path: root/share/extensions/test/gimp_xcf.test.py
blob: b5a530a49989f917648c3f88e7b82a59f3143c8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
'''
Unit test file for ../gimp_xcf.py
Revision history:
  * 2012-01-26 (jazzynico): checks defaulf parameters and file handling.

--
If you want to help, read the python unittest documentation:
http://docs.python.org/library/unittest.html
'''

import os
import sys
import unittest

sys.path.append('..') # this line allows to import the extension code
from gimp_xcf import *

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 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)


if __name__ == '__main__':
    #unittest.main()
    suite = unittest.TestLoader().loadTestsFromTestCase(GimpXCFBasicTest)
    unittest.TextTestRunner(verbosity=2).run(suite)