4 # Copyright (C) 2010-2018 CEA/DEN
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.
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.
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
24 from src.salomeTools import Sat
25 from unittestpy.tools import outRedirection
27 class TestCase(unittest.TestCase):
28 "Test the jobs command"""
31 # Test the jobs command
33 tmp_file = "/tmp/test.txt"
35 sat = Sat("-l " + tmp_file)
37 # Execute the jobs command
38 sat.jobs("--name .test --publish" )
40 ff = open(tmp_file, "r")
41 log_files = ff.readlines()
44 log_jobs = [line.replace("\n", "") for line in log_files if 'jobs.xml' in line]
46 text = open(log_jobs[0], "r").read()
49 "Establishing connection with all the machines",
55 for exp_res in expected_res:
56 if exp_res not in text:
61 self.assertEqual(OK, 'OK')
64 # Test the jobs command with option --only_jobs
66 tmp_file = "/tmp/test.txt"
68 sat = Sat("-l " + tmp_file)
70 # Execute the jobs command
71 sat.jobs("--name .test --publish --only_jobs Job 1" )
73 ff = open(tmp_file, "r")
74 log_files = ff.readlines()
77 log_jobs = [line.replace("\n", "") for line in log_files if 'jobs.xml' in line]
79 text = open(log_jobs[0], "r").read()
82 "Establishing connection with all the machines",
88 for exp_res in expected_res:
89 if exp_res not in text:
94 self.assertEqual(OK, 'OK')
97 # Test the jobs command without --name option
99 tmp_file = "/tmp/test.txt"
101 sat = Sat("-l " + tmp_file)
103 # Execute the job command
108 self.assertEqual(OK, 'OK')
111 # Test the jobs command with a wrong file configuration
113 tmp_file = "/tmp/test.txt"
115 sat = Sat("-l " + tmp_file)
117 # Execute the job command
118 res = sat.jobs("--name NOTEXIST" )
122 self.assertEqual(OK, 'OK')
125 # Test the display of the right value of 'sat jobs --list'
129 my_out = outRedirection()
131 # The command to test
135 # stop output redirection
136 my_out.end_redirection()
139 res = my_out.read_results()
142 if "ERROR" not in res:
144 self.assertEqual(OK, "OK")
147 # Test the sat -h jobs
152 if "The jobs command launches maintenances that are described in the dedicated jobs configuration file." in jobs.description():
154 self.assertEqual(OK, "OK")
157 if __name__ == '__main__':