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
24 testdir = os.path.dirname(os.path.realpath(__file__))
25 sys.path.append(os.path.join(testdir, '..', '..'))
26 sys.path.append(os.path.join(testdir, '..', '_testTools'))
27 sys.path.append(os.path.join(testdir, '..', '..','commands'))
29 from salomeTools import Sat
32 class TestShell(unittest.TestCase):
33 '''Test of the shell command
37 '''Test the shell command with the --command option
40 tmp_file = "/tmp/test.txt"
42 sat = Sat("-l " + tmp_file)
45 sat_way = sat.cfg.VARS.salometoolsway
47 # Execute the shell command
48 sat.shell("--command ls " + sat_way)
50 ff = open(tmp_file, "r")
51 log_files = ff.readlines()
54 log_files = [line.replace("\n", "") for line in log_files]
56 text = open(log_files[2], "r").read()
58 if "salomeTools.py" in text:
60 # pyunit method to compare 2 str
61 self.assertEqual(OK, 'OK')
63 def test_failing_shell(self):
64 '''Test the shell command with the --command option with a failing command
67 tmp_file = "/tmp/test.txt"
69 sat = Sat("-l " + tmp_file)
73 # Execute the shell command
74 res = sat.shell("--command i_fail")
76 ff = open(tmp_file, "r")
77 log_files = ff.readlines()
80 log_files = [line.replace("\n", "") for line in log_files]
82 text = open(log_files[2], "r").read()
84 if "i_fail" in text and res == 1:
86 # pyunit method to compare 2 str
87 self.assertEqual(OK, 'OK')
89 def test_description(self):
90 '''Test the sat -h shell
97 if "Executes the shell command passed as argument" in shell.description():
100 # pyunit method to compare 2 str
101 self.assertEqual(OK, "OK")
104 if __name__ == '__main__':
105 HTMLTestRunner.main()