from salomeTools import Sat
from tools import check_proc_existence_and_kill
-from tools import outRedirection
import HTMLTestRunner
-import src.xmlManager
-sleep_time = 3
+sleep_time = 2
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(sleep_time)
-
- 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
'''
sat.config('appli-test -v USER.browser')
# get log file path
- logDir = sat.cfg.SITE.log.logDir
+ logDir = sat.cfg.SITE.log.log_dir
logPath = os.path.join(logDir, sat.cfg.VARS.datehour + "_" + sat.cfg.VARS.command + ".xml")
if os.path.exists(logPath):
OK = "OK"
sys.stdin = sys.__stdin__
except:
- pass
+ sys.stdin = sys.__stdin__
# pyunit method to compare 2 str
self.assertEqual(OK, "OK")
sys.stdin = io.StringIO(one)
try:
- sat.log('appli-test --last')
+ sat.log('appli-test -t --last')
OK = "OK"
sys.stdin = sys.__stdin__
except:
sat.config('appli-test -v VARS.python')
- nb_logs = len(os.listdir(sat.cfg.SITE.log.logDir))
+ nb_logs = len(os.listdir(sat.cfg.SITE.log.log_dir))
nb_logs_u = unicode(str(nb_logs) + "\n1")
sys.stdin = io.StringIO(nb_logs_u)
# pyunit method to compare 2 str
self.assertEqual(OK, "OK")
-
+
def test_option_last(self):
'''Test the option --last
'''
sat.config('appli-test -v VARS.python')
+
+ time.sleep(sleep_time)
cmd_log = threading.Thread(target=sat.log, args=('appli-test --last',))
cmd_log.start()
# pyunit method to compare 2 str
self.assertEqual(OK, "OK")
-
+
def test_option_clean(self):
'''Test the option --clean
'''
sat.config('-v VARS.user')
- nb_logs_t0 = len(os.listdir(sat.cfg.SITE.log.logDir))
+ nb_logs_t0 = len(os.listdir(sat.cfg.SITE.log.log_dir))
sat.log('--clean 1')
- nb_logs_t1 = len(os.listdir(sat.cfg.SITE.log.logDir))
+ nb_logs_t1 = len(os.listdir(sat.cfg.SITE.log.log_dir))
if nb_logs_t1-nb_logs_t0 == 0:
OK = "OK"
sat.config('-v VARS.user')
- nb_logs_t0 = len(os.listdir(sat.cfg.SITE.log.logDir))
+ nb_logs_t0 = len(os.listdir(sat.cfg.SITE.log.log_dir))
- if os.path.exists(sat.cfg.SITE.log.logDir + "_save"):
- shutil.rmtree(sat.cfg.SITE.log.logDir + "_save")
- shutil.copytree(sat.cfg.SITE.log.logDir,sat.cfg.SITE.log.logDir + "_save")
+ if os.path.exists(sat.cfg.SITE.log.log_dir + "_save"):
+ shutil.rmtree(sat.cfg.SITE.log.log_dir + "_save")
+ shutil.copytree(sat.cfg.SITE.log.log_dir,sat.cfg.SITE.log.log_dir + "_save")
sat.log('--clean ' + str(nb_logs_t0))
- nb_logs_t1 = len(os.listdir(sat.cfg.SITE.log.logDir))
+ nb_logs_t1 = len(os.listdir(sat.cfg.SITE.log.log_dir))
- shutil.rmtree(sat.cfg.SITE.log.logDir)
- shutil.move(sat.cfg.SITE.log.logDir + "_save", sat.cfg.SITE.log.logDir)
+ shutil.rmtree(sat.cfg.SITE.log.log_dir)
+ shutil.move(sat.cfg.SITE.log.log_dir + "_save", sat.cfg.SITE.log.log_dir)
if nb_logs_t0-nb_logs_t1 > 10:
OK = "OK"
# pyunit method to compare 2 str
self.assertEqual(OK, "OK")
-
+
+ """
def test_option_full(self):
'''Test the option --full
'''
OK = "KO"
sat = Sat("-oUSER.browser='konqueror'")
+ time.sleep(sleep_time)
cmd_log = threading.Thread(target=sat.log, args=('--full',))
cmd_log.start()
time.sleep(sleep_time)
browser = sat.cfg.USER.browser
- check_proc_existence_and_kill(browser + ".*" + "xml")
+ check_proc_existence_and_kill(browser + ".*" + "hat\.xml")
# Read and check the hat.xml file contains at least one log file corresponding to log
- hatFilePath = os.path.join(sat.cfg.SITE.log.logDir, "hat.xml")
+ hatFilePath = os.path.join(sat.cfg.SITE.log.log_dir, "hat.xml")
xmlHatFile = src.xmlManager.ReadXmlFile(hatFilePath)
for field in xmlHatFile.xmlroot:
if field.attrib[b'cmd'] == b'log':
# pyunit method to compare 2 str
self.assertEqual(OK, "OK")
-
+ """
def test_description(self):
'''Test the sat -h log
'''