Salome HOME
add AllTestLauncher and src/loggingSimple.py etc...
[tools/sat.git] / test / test_sat5_0 / config / test_option_value.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3
4 #  Copyright (C) 2010-2018  CEA/DEN
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19
20 import os
21 import sys
22 import platform
23 import unittest
24
25 from src.salomeTools import Sat
26 from unittestpy.tools import outRedirection
27
28 class TestCase(unittest.TestCase):
29     """sat config --value"""
30     
31     def test_010(self):
32         # Test the display of the right value of "sat config -v VARS.hostname"
33         OK = "KO"
34
35         # output redirection
36         my_out = outRedirection()
37
38         # The command to test
39         sat = Sat()
40         sat.config('-v VARS.hostname')
41
42         # stop output redirection
43         my_out.end_redirection()
44
45         # get results
46         res = my_out.read_results()
47
48         if platform.node() in res:
49             OK = "OK"
50         self.assertEqual(OK, "OK")
51
52     def test_020(self):
53         # Test the display of the right value of "sat config -l"
54         OK = "KO"
55
56         # output redirection
57         my_out = outRedirection()
58
59         # The command to test
60         sat = Sat()
61         sat.config('-l')
62
63         # stop output redirection
64         my_out.end_redirection()
65
66         # get results
67         res = my_out.read_results()
68
69         # get results
70         if "ERROR" not in res:
71             OK = "OK"
72         self.assertEqual(OK, "OK")
73     
74     """    
75     def test_030(self):
76         # Test the exception when salomeTools.pyconf has errors           
77         OK = "KO"
78         
79         # The command to test
80         sat = Sat()
81         sat.config()
82         
83         salomeToolspyconfPath = os.path.join(sat.cfg.VARS.srcDir, "internal_config", "salomeTools.pyconf")
84         salomeToolspyconfPath_save = os.path.join(sat.cfg.VARS.srcDir, "internal_config", "salomeTools.pyconf_save")
85         if os.path.exists(salomeToolspyconfPath_save):
86             os.remove(salomeToolspyconfPath_save)
87         shutil.copyfile(salomeToolspyconfPath, salomeToolspyconfPath_save)
88         f_read = open(salomeToolspyconfPath, 'r')
89         text = f_read.read()
90         f_read.close()
91         os.remove(salomeToolspyconfPath)
92         f_write = open(salomeToolspyconfPath, 'w')
93         f_write.write(text.replace(':', ''))
94         f_write.close()
95         
96         try:
97             sat.config()
98         except TypeError:
99             OK = "OK"
100         finally:
101             shutil.copyfile(salomeToolspyconfPath_save, salomeToolspyconfPath)
102             os.remove(salomeToolspyconfPath_save)
103         self.assertEqual(OK, "OK")
104     """       
105         
106 # test launch
107 if __name__ == '__main__':
108     unittest.main()
109     pass