Salome HOME
f0a1b130b3a7105185a891bcb7ccacc1fe72ca07
[tools/sat.git] / test / config / option_edit.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 import src
32 from tools import outRedirection
33 from tools import check_proc_existence_and_kill
34 import HTMLTestRunner
35
36 sleep_time = 3
37
38 class TestConfig(unittest.TestCase):
39     '''OPTION EDIT.
40     '''
41     
42     def test_edit_userconfig(self):
43         '''Test the launch of the editor when invoking the config -e
44         '''
45
46         OK = "KO"
47
48         sat = Sat("-oUSER.editor='cooledit'")
49         cmd_config = threading.Thread(target=sat.config, args=('-e',))
50         cmd_config.start()
51
52         time.sleep(sleep_time)
53
54         editor = sat.cfg.USER.editor
55         pid = check_proc_existence_and_kill(editor + ".*" + "salomeTools\.pyconf")
56
57         if pid:
58             OK = "OK"
59         # pyunit method to compare 2 str
60         self.assertEqual(OK, "OK")
61
62     def test_edit_appli(self):
63         '''Test the launch of the editor when invoking the config -e appli-test
64         '''
65
66         OK = "KO"
67
68         sat = Sat("-oUSER.editor='cooledit'")
69         cmd_config = threading.Thread(target=sat.config, args=('appli-test -e',))
70         cmd_config.start()
71
72         time.sleep(sleep_time)
73
74         editor = sat.cfg.USER.editor
75         pid = check_proc_existence_and_kill(editor + ".*" + "appli-test\.pyconf")
76
77         if pid:
78             OK = "OK"
79         # pyunit method to compare 2 str
80         self.assertEqual(OK, "OK")
81  
82 # test launch
83 if __name__ == '__main__':
84     HTMLTestRunner.main()