X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=test%2Flog%2Flaunch_browser.py;fp=test%2Flog%2Flaunch_browser.py;h=3014474f9d5a02364f94bb6b7757a400169a6e56;hb=a3c9eb45aa029182bbe6e2d31c2957cc06bf293d;hp=0000000000000000000000000000000000000000;hpb=d3c70f613d879ae88980ee21c95f62e7323ba203;p=tools%2Fsat.git diff --git a/test/log/launch_browser.py b/test/log/launch_browser.py new file mode 100644 index 0000000..3014474 --- /dev/null +++ b/test/log/launch_browser.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- +# Copyright (C) 2010-2012 CEA/DEN +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import unittest +import os +import sys +import threading +import time + +# get execution path +testdir = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(testdir, '..', '..')) +sys.path.append(os.path.join(testdir, '..', '_testTools')) + +from salomeTools import Sat +from tools import check_proc_existence_and_kill +import HTMLTestRunner + +class TestLog(unittest.TestCase): + '''Test of log command: launch of browser + ''' + + def test_launch_browser(self): + '''Test the launch of browser when invoking the log command + ''' + + OK = "KO" + + sat = Sat("-oUSER.browser='konqueror'") + cmd_log = threading.Thread(target=sat.log, args=('',)) + cmd_log.start() + + time.sleep(2) + + browser = sat.cfg.USER.browser + pid = check_proc_existence_and_kill(browser + ".*" + "xml") + + if pid: + OK = "OK" + # pyunit method to compare 2 str + self.assertEqual(OK, "OK") + + def test_write_xmllog(self): + '''Test the write of xml log when invoking a command + ''' + + OK = "KO" + + # launch the command that will write a log + sat = Sat() + sat.config('appli-test -v USER.browser') + + # get log file path + logDir = sat.cfg.VARS.logDir + logPath = os.path.join(logDir, sat.cfg.VARS.datehour + "_" + sat.cfg.VARS.command + ".xml") + + if os.path.exists(logPath): + OK = "OK" + + # pyunit method to compare 2 str + self.assertEqual(OK, "OK") + + def test_option_terminal(self): + '''Test the write of xml log when invoking a command + ''' + + OK = "KO" + + # launch the command that will write a log + sat = Sat() + + # overwrite the raw_input function in order to be able to test + new_ask_value = lambda x: 1 + sys.modules['log'].ask_value = new_ask_value + + try: + sat.log('-t') + OK = "OK" + except: + pass + + # pyunit method to compare 2 str + self.assertEqual(OK, "OK") + + def test_option_terminal2(self): + '''Test the write of xml log when invoking a command + ''' + + OK = "KO" + + # launch the command that will write a log + sat = Sat() + + # overwrite the raw_input function in order to be able to test + new_ask_value = lambda x: 1 + sys.modules['log'].ask_value = new_ask_value + + sat.config('appli-test -v VARS.python') + + try: + sat.log('appli-test -t') + OK = "OK" + except: + pass + + # pyunit method to compare 2 str + self.assertEqual(OK, "OK") + +# test launch +if __name__ == '__main__': + HTMLTestRunner.main()