Salome HOME
Merge branch 'BR_8_3' of https://codev-tuleap.cea.fr/plugins/git/spns/SAT into BR_8_3
[tools/sat.git] / test / test / test_command.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 #  Copyright (C) 2010-2012  CEA/DEN
4 #
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.
9 #
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.
14 #
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
18
19 import unittest
20 import os
21 import sys
22
23 # get execution path
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'))
28
29 from salomeTools import Sat
30 import HTMLTestRunner
31
32 class TestTest(unittest.TestCase):
33     '''Test of the test command
34     '''
35
36     def test_test(self):
37         '''Test the test command
38         '''
39         OK = 'KO'
40         tmp_file = "/tmp/test.txt"
41         application = "SALOME-7.8.0"
42
43         sat = Sat("-l " + tmp_file)
44         
45         # Execute the job command
46         sat.test(application + " --grid GEOM --session light" )
47
48         ff = open(tmp_file, "r")
49         log_files = ff.readlines()
50         ff.close()
51         os.remove(tmp_file)
52         log_testboard = [line.replace("\n", "") for line in log_files if 'testboard.xml' in line]
53         
54         text = open(log_testboard[0], "r").read()
55
56         if '<session name="light">' in text:
57             OK = 'OK'         
58         # pyunit method to compare 2 str
59         self.assertEqual(OK, 'OK')
60
61     def test_PY_test(self):
62         '''Test the test command with PY type
63         '''
64         OK = 'KO'
65         tmp_file = "/tmp/test.txt"
66         application = "SALOME-7.8.0"
67
68         sat = Sat("-l " + tmp_file)
69         
70         # Execute the job command
71         sat.test(application + " --grid MED --session PY_test_withKernel" )
72
73         ff = open(tmp_file, "r")
74         log_files = ff.readlines()
75         ff.close()
76         os.remove(tmp_file)
77         log_testboard = [line.replace("\n", "") for line in log_files if 'testboard.xml' in line]
78         
79         text = open(log_testboard[0], "r").read()
80
81         if '<session name="PY_test_withKernel">' in text:
82             OK = 'OK'         
83         # pyunit method to compare 2 str
84         self.assertEqual(OK, 'OK')
85
86     def test_description(self):
87         '''Test the sat -h test
88         '''        
89
90         OK = "KO"
91
92         import test
93         
94         if "The test command runs a test base on a SALOME installation" in test.description():
95             OK = "OK"
96
97         # pyunit method to compare 2 str
98         self.assertEqual(OK, "OK")
99
100 # test launch
101 if __name__ == '__main__':
102     HTMLTestRunner.main()