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
26 class TestCase(unittest.TestCase):
27 """Test the job command"""
30 # Test the job command
32 tmp_file = "/tmp/test.txt"
34 sat = Sat("-l " + tmp_file)
36 # Execute the job command
37 sat.job("--jobs_config .test --name Job 1" )
39 ff = open(tmp_file, "r")
40 log_files = ff.readlines()
43 log_config = [line.replace("\n", "") for line in log_files if 'config.xml' in line]
45 text = open(log_config[0], "r").read()
49 self.assertEqual(OK, 'OK')
53 # Test the job command with a failing command
55 tmp_file = "/tmp/test.txt"
57 sat = Sat("-l " + tmp_file)
59 # Execute the job command
60 res = sat.job("--jobs_config .test --name Job 4" )
64 # pyunit method to compare 2 str
65 self.assertEqual(OK, 'OK')
68 # Test the job command with a wrong file configuration
70 tmp_file = "/tmp/test.txt"
72 sat = Sat("-l " + tmp_file)
74 # Execute the job command
75 res = sat.job("--jobs_config NOTEXIST --name Job 4" )
79 self.assertEqual(OK, 'OK')
82 # Test the job command without --jobs_config option
84 tmp_file = "/tmp/test.txt"
86 sat = Sat("-l " + tmp_file)
88 # Execute the job command
89 res = sat.job("--name Job 4" )
93 self.assertEqual(OK, 'OK')
96 # Test the job command without --jobs_config option
98 tmp_file = "/tmp/test.txt"
100 sat = Sat("-l " + tmp_file)
102 # Execute the job command
103 res = sat.job("--jobs_config .test --name NOTEXIST" )
107 self.assertEqual(OK, 'OK')
110 # Test the sat -h job
115 if "Executes the commands of the job defined in the jobs configuration file" in job.description():
117 self.assertEqual(OK, "OK")
120 if __name__ == '__main__':