]> SALOME platform Git repositories - tools/sat.git/blob - test/log/launch_browser.py
Salome HOME
try to be cdash like in xml log files
[tools/sat.git] / test / log / launch_browser.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 import threading
23 import time
24
25 # get execution path
26 testdir = os.path.dirname(os.path.realpath(__file__))
27 sys.path.append(os.path.join(testdir, '..', '..'))
28 sys.path.append(os.path.join(testdir, '..', '_testTools'))
29
30 from salomeTools import Sat
31 from tools import check_proc_existence_and_kill
32 import HTMLTestRunner
33
34 class TestLog(unittest.TestCase):
35     '''Test of log command: launch of browser
36     '''
37     
38     def test_launch_browser(self):
39         '''Test the launch of browser when invoking the log command
40         '''
41
42         OK = "KO"
43
44         sat = Sat("-oUSER.browser='konqueror'")
45         cmd_log = threading.Thread(target=sat.log, args=('',))
46         cmd_log.start()
47
48         time.sleep(2)
49
50         browser = sat.cfg.USER.browser
51         pid = check_proc_existence_and_kill(browser + ".*" + "xml")
52
53         if pid:
54             OK = "OK"
55         # pyunit method to compare 2 str
56         self.assertEqual(OK, "OK")
57         
58     def test_write_xmllog(self):
59         '''Test the write of xml log when invoking a command
60         '''
61
62         OK = "KO"
63         
64         # launch the command that will write a log
65         sat = Sat()
66         sat.config('appli-test -v USER.browser')
67         
68         # get log file path
69         logDir = sat.cfg.VARS.logDir
70         logPath = os.path.join(logDir, sat.cfg.VARS.datehour + "_" + sat.cfg.VARS.command + ".xml")
71         
72         if os.path.exists(logPath):
73             OK = "OK"
74         
75         # pyunit method to compare 2 str
76         self.assertEqual(OK, "OK")
77
78     def test_option_terminal(self):
79         '''Test the write of xml log when invoking a command
80         '''
81
82         OK = "KO"
83         
84         # launch the command that will write a log
85         sat = Sat()
86         
87         # overwrite the raw_input function in order to be able to test
88         new_ask_value = lambda x: 1
89         sys.modules['log'].ask_value = new_ask_value
90         
91         try:
92             sat.log('-t')
93             OK = "OK"
94         except:
95             pass
96         
97         # pyunit method to compare 2 str
98         self.assertEqual(OK, "OK")
99
100     def test_option_terminal2(self):
101         '''Test the write of xml log when invoking a command
102         '''
103
104         OK = "KO"
105         
106         # launch the command that will write a log
107         sat = Sat()
108         
109         # overwrite the raw_input function in order to be able to test
110         new_ask_value = lambda x: 1
111         sys.modules['log'].ask_value = new_ask_value
112         
113         sat.config('appli-test -v VARS.python')
114         
115         try:
116             sat.log('appli-test -t')
117             OK = "OK"
118         except:
119             pass
120         
121         # pyunit method to compare 2 str
122         self.assertEqual(OK, "OK")
123
124 # test launch
125 if __name__ == '__main__':
126     HTMLTestRunner.main()