3 # Copyright (C) 2010-2012 CEA/DEN
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.
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.
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
26 testdir = os.path.dirname(os.path.realpath(__file__))
27 sys.path.append(os.path.join(testdir, '..', '..'))
28 sys.path.append(os.path.join(testdir, '..', '_testTools'))
30 from salomeTools import Sat
32 from tools import outRedirection
35 class TestConfig(unittest.TestCase):
39 def test_option_value(self):
40 '''Test the display of the right value of "sat config -v VARS.hostname"
46 my_out = outRedirection()
50 sat.config('-v VARS.hostname')
52 # stop output redirection
53 my_out.end_redirection()
56 res = my_out.read_results()
58 if platform.node() in res:
61 # pyunit method to compare 2 str
62 self.assertEqual(OK, "OK")
64 def test_option_list(self):
65 '''Test the display of the right value of "sat config -l"
71 my_out = outRedirection()
77 # stop output redirection
78 my_out.end_redirection()
81 res = my_out.read_results()
84 if "ERROR" not in res:
87 # pyunit method to compare 2 str
88 self.assertEqual(OK, "OK")
91 def test_error_salomeToolspyconf(self):
92 '''Test the exception when salomeTools.pyconf has errors
101 salomeToolspyconfPath = os.path.join(sat.cfg.VARS.srcDir, "internal_config", "salomeTools.pyconf")
102 salomeToolspyconfPath_save = os.path.join(sat.cfg.VARS.srcDir, "internal_config", "salomeTools.pyconf_save")
103 if os.path.exists(salomeToolspyconfPath_save):
104 os.remove(salomeToolspyconfPath_save)
105 shutil.copyfile(salomeToolspyconfPath, salomeToolspyconfPath_save)
106 f_read = open(salomeToolspyconfPath, 'r')
109 os.remove(salomeToolspyconfPath)
110 f_write = open(salomeToolspyconfPath, 'w')
111 f_write.write(text.replace(':', ''))
119 shutil.copyfile(salomeToolspyconfPath_save, salomeToolspyconfPath)
120 os.remove(salomeToolspyconfPath_save)
122 # pyunit method to compare 2 str
123 self.assertEqual(OK, "OK")
127 if __name__ == '__main__':
128 HTMLTestRunner.main()