4 # Copyright (C) 2010-2018 CEA/DEN
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 from src.salomeTools import Sat
27 class TestCase(unittest.TestCase):
28 """Test create file .pyconf"""
31 # Test creation of ~/.salomeTools/salomeTools.pyconf
32 print "stupidity HAVE TO NOT touch user ~/.salomeTools"
36 user_dir = os.path.expanduser(os.path.join('~','.salomeTools'))
37 user_dir_save = os.path.expanduser(os.path.join('~','.salomeTools_save'))
38 if os.path.exists(user_dir_save):
39 shutil.rmtree(user_dir_save)
40 if os.path.exists(user_dir):
41 shutil.move(user_dir, user_dir_save)
47 expected_file = os.path.expanduser(os.path.join('~','.salomeTools', 'salomeTools.pyconf'))
49 if os.path.exists(expected_file):
52 shutil.rmtree(user_dir)
53 shutil.move(user_dir_save, user_dir)
54 self.assertEqual(res, "OK")
61 sat = Sat("-oVARS.user='user_test'")
64 if sat.cfg.VARS.user == 'user_test':
66 self.assertEqual(OK, "OK")
69 # Test override INTERNAL
73 sat = Sat("-oINTERNAL.sat_version='V0'")
76 if sat.cfg.INTERNAL.sat_version == 'V0':
78 self.assertEqual(OK, "OK")
86 sat = Sat("-oSITE.jobs.config_path='/tmp'")
89 if sat.cfg.SITE.jobs.config_path == '/tmp':
92 self.assertEqual(OK, "OK")
96 # Test override APPLICATION
100 sat = Sat("-oAPPLICATION.out_dir='/tmp'")
101 sat.config('appli-test')
103 if sat.cfg.APPLICATION.out_dir == '/tmp':
105 self.assertEqual(OK, "OK")
108 # Test override PRODUCTS
111 # The command to test
112 sat = Sat("-oPRODUCTS.PRODUCT_GIT.default.name='test'")
115 if sat.cfg.PRODUCTS.PRODUCT_GIT.default.name == 'test':
117 self.assertEqual(OK, "OK")
120 if __name__ == '__main__':