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 TestJob(unittest.TestCase):
33 '''Test of the job command
37 '''Test the job command
40 tmp_file = "/tmp/test.txt"
42 sat = Sat("-l " + tmp_file)
44 # Execute the job command
45 sat.job("--jobs_config .test --name Job 1" )
47 ff = open(tmp_file, "r")
48 log_files = ff.readlines()
51 log_config = [line.replace("\n", "") for line in log_files if 'config.xml' in line]
53 text = open(log_config[0], "r").read()
57 # pyunit method to compare 2 str
58 self.assertEqual(OK, 'OK')
61 def test_failing_job(self):
62 '''Test the job command with a failing command
65 tmp_file = "/tmp/test.txt"
67 sat = Sat("-l " + tmp_file)
69 # Execute the job command
70 res = sat.job("--jobs_config .test --name Job 4" )
74 # pyunit method to compare 2 str
75 self.assertEqual(OK, 'OK')
77 def test_file_conf_not_found(self):
78 '''Test the job command with a wrong file configuration
81 tmp_file = "/tmp/test.txt"
83 sat = Sat("-l " + tmp_file)
85 # Execute the job command
86 res = sat.job("--jobs_config NOTEXIST --name Job 4" )
90 # pyunit method to compare 2 str
91 self.assertEqual(OK, 'OK')
93 def test_no_option_jobs_config(self):
94 '''Test the job command without --jobs_config option
97 tmp_file = "/tmp/test.txt"
99 sat = Sat("-l " + tmp_file)
101 # Execute the job command
102 res = sat.job("--name Job 4" )
106 # pyunit method to compare 2 str
107 self.assertEqual(OK, 'OK')
109 def test_job_not_found(self):
110 '''Test the job command without --jobs_config option
113 tmp_file = "/tmp/test.txt"
115 sat = Sat("-l " + tmp_file)
117 # Execute the job command
118 res = sat.job("--jobs_config .test --name NOTEXIST" )
122 # pyunit method to compare 2 str
123 self.assertEqual(OK, 'OK')
125 def test_description(self):
126 '''Test the sat -h job
133 if "Executes the commands of the job defined in the jobs configuration file" in job.description():
136 # pyunit method to compare 2 str
137 self.assertEqual(OK, "OK")
140 if __name__ == '__main__':
141 HTMLTestRunner.main()