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
28 class TestCase(unittest.TestCase):
29 "Test the jobs command" ""
32 # Test the jobs command
34 tmp_file = "/tmp/test.txt"
36 sat = Sat("-l " + tmp_file)
38 # Execute the jobs command
39 sat.jobs("--name .test --publish")
41 ff = open(tmp_file, "r")
42 log_files = ff.readlines()
45 log_jobs = [line.replace("\n", "") for line in log_files if "jobs.xml" in line]
47 text = open(log_jobs[0], "r").read()
50 "Establishing connection with all the machines",
56 for exp_res in expected_res:
57 if exp_res not in text:
62 self.assertEqual(OK, "OK")
65 # Test the jobs command with option --only_jobs
67 tmp_file = "/tmp/test.txt"
69 sat = Sat("-l " + tmp_file)
71 # Execute the jobs command
72 sat.jobs("--name .test --publish --only_jobs Job 1")
74 ff = open(tmp_file, "r")
75 log_files = ff.readlines()
78 log_jobs = [line.replace("\n", "") for line in log_files if "jobs.xml" in line]
80 text = open(log_jobs[0], "r").read()
83 "Establishing connection with all the machines",
89 for exp_res in expected_res:
90 if exp_res not in text:
95 self.assertEqual(OK, "OK")
98 # Test the jobs command without --name option
100 tmp_file = "/tmp/test.txt"
102 sat = Sat("-l " + tmp_file)
104 # Execute the job command
109 self.assertEqual(OK, "OK")
112 # Test the jobs command with a wrong file configuration
114 tmp_file = "/tmp/test.txt"
116 sat = Sat("-l " + tmp_file)
118 # Execute the job command
119 res = sat.jobs("--name NOTEXIST")
123 self.assertEqual(OK, "OK")
126 # Test the display of the right value of 'sat jobs --list'
130 my_out = outRedirection()
132 # The command to test
136 # stop output redirection
137 my_out.end_redirection()
140 res = my_out.read_results()
143 if "ERROR" not in res:
145 self.assertEqual(OK, "OK")
148 # Test the sat -h jobs
154 "The jobs command launches maintenances that are described in the dedicated jobs configuration file."
155 in jobs.description()
158 self.assertEqual(OK, "OK")
162 if __name__ == "__main__":