Salome HOME
style: black format
[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
29 class TestCase(unittest.TestCase):
30     """sat config --value"""
31
32     def test_010(self):
33         # Test the display of the right value of "sat config -v VARS.hostname"
34         OK = "KO"
35
36         # output redirection
37         my_out = outRedirection()
38
39         # The command to test
40         sat = Sat()
41         sat.config("-v VARS.hostname")
42
43         # stop output redirection
44         my_out.end_redirection()
45
46         # get results
47         res = my_out.read_results()
48
49         if platform.node() in res:
50             OK = "OK"
51         self.assertEqual(OK, "OK")
52
53     def test_020(self):
54         # Test the display of the right value of "sat config -l"
55         OK = "KO"
56
57         # output redirection
58         my_out = outRedirection()
59
60         # The command to test
61         sat = Sat()
62         sat.config("-l")
63
64         # stop output redirection
65         my_out.end_redirection()
66
67         # get results
68         res = my_out.read_results()
69
70         # get results
71         if "ERROR" not in res:
72             OK = "OK"
73         self.assertEqual(OK, "OK")
74
75     """    
76     def test_030(self):
77         # Test the exception when salomeTools.pyconf has errors           
78         OK = "KO"
79         
80         # The command to test
81         sat = Sat()
82         sat.config()
83         
84         salomeToolspyconfPath = os.path.join(sat.cfg.VARS.srcDir, "internal_config", "salomeTools.pyconf")
85         salomeToolspyconfPath_save = os.path.join(sat.cfg.VARS.srcDir, "internal_config", "salomeTools.pyconf_save")
86         if os.path.exists(salomeToolspyconfPath_save):
87             os.remove(salomeToolspyconfPath_save)
88         shutil.copyfile(salomeToolspyconfPath, salomeToolspyconfPath_save)
89         f_read = open(salomeToolspyconfPath, 'r')
90         text = f_read.read()
91         f_read.close()
92         os.remove(salomeToolspyconfPath)
93         f_write = open(salomeToolspyconfPath, 'w')
94         f_write.write(text.replace(':', ''))
95         f_write.close()
96         
97         try:
98             sat.config()
99         except TypeError:
100             OK = "OK"
101         finally:
102             shutil.copyfile(salomeToolspyconfPath_save, salomeToolspyconfPath)
103             os.remove(salomeToolspyconfPath_save)
104         self.assertEqual(OK, "OK")
105     """
106
107
108 # test launch
109 if __name__ == "__main__":
110     unittest.main()
111     pass