Salome HOME
Test procedure improvement. Add of HTMLTestRunner.py
[tools/sat.git] / test / config / integration / option_value_2.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 #  Copyright (C) 2010-2012  CEA/DEN
4 #
5 #  This library is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU Lesser General Public
7 #  License as published by the Free Software Foundation; either
8 #  version 2.1 of the License.
9 #
10 #  This library is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 #  Lesser General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Lesser General Public
16 #  License along with this library; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18
19 import unittest
20 import os
21 import sys
22
23 # get execution path
24 testdir = os.path.dirname(os.path.realpath(__file__))
25 sys.path.append(os.path.join(testdir, '..', '..', '..', 'src'))
26 sys.path.append(os.path.join(testdir, '..', '..', '..', 'test', '__TOOLS__'))
27
28 from salomeTools import salomeTools
29 from tools import outRedirection
30 import HTMLTestRunner
31
32 class TestConfig(unittest.TestCase):
33     '''pyunit class : each method execute one test.
34     '''
35     
36     def test_option_value(self):
37         '''Test the display of the right value of "sat config -v VARS.hostname"
38         '''
39         # expected value
40         expected = '\x1b[36mhostname\x1b[0m: is221560\n'
41
42         # output redirection
43         my_out = outRedirection()
44
45         # The command to test
46         sat = salomeTools('')
47         sat.config('-v VARS.python')
48
49         # stop output redirection
50         my_out.end_redirection()
51
52         # get results
53         res = my_out.read_results()
54
55         # pyunit method to compare 2 str
56         self.assertEqual(res, expected)
57
58     def test_option_list(self):
59         '''Test the display of the right value of "sat config -l"
60         '''
61         # expected value
62         expected = '------ \x1b[34m/home/salome/SPN_PRIVATE/sat5dev_Applications\x1b[0m\nappli-test\n\n------ \x1b[34m/export/home/serioja/.salomeTools/Applications\x1b[0m\n\n'
63
64         # output redirection
65         my_out = outRedirection()
66
67         # The command to test
68         sat = salomeTools('')
69         sat.config('-l')
70
71         # stop output redirection
72         my_out.end_redirection()
73
74         # get results
75         res = my_out.read_results()
76
77         # pyunit method to compare 2 str
78         self.assertEqual(res, expected)
79
80 # test launch
81 if __name__ == '__main__':
82     HTMLTestRunner.main()