3 # Copyright (C) 2010-2012 CEA/DEN
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.
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.
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
25 testdir = os.path.dirname(os.path.realpath(__file__))
26 sys.path.append(os.path.join(testdir, '..', '..'))
27 sys.path.append(os.path.join(testdir, '..', '_testTools'))
29 from salomeTools import Sat
32 class TestConfig(unittest.TestCase):
33 '''pyunit class : each method execute one test.
36 def test_user_dir_creation(self):
37 '''Creation of ~/.salomeTools/salomeTools.pyconf
40 user_dir = os.path.expanduser(os.path.join('~','.salomeTools'))
41 user_dir_save = os.path.expanduser(os.path.join('~','.salomeTools_save'))
42 if os.path.exists(user_dir_save):
43 shutil.rmtree(user_dir_save)
44 if os.path.exists(user_dir):
45 shutil.move(user_dir, user_dir_save)
51 expected_file = os.path.expanduser(os.path.join('~','.salomeTools', 'salomeTools.pyconf'))
53 if os.path.exists(expected_file):
56 shutil.rmtree(user_dir)
57 shutil.move(user_dir_save, user_dir)
59 # pyunit method to compare 2 str
60 self.assertEqual(res, "OK")
62 def test_override_VARS(self):
68 sat = Sat("-oVARS.user='user_test'")
71 if sat.cfg.VARS.user == 'user_test':
74 # pyunit method to compare 2 str
75 self.assertEqual(OK, "OK")
77 def test_override_INTERNAL(self):
83 sat = Sat("-oINTERNAL.sat_version='V0'")
86 if sat.cfg.INTERNAL.sat_version == 'V0':
89 # pyunit method to compare 2 str
90 self.assertEqual(OK, "OK")
92 def test_override_SITE(self):
98 sat = Sat("-oSITE.prepare.default_git_server='testgit'")
101 if sat.cfg.SITE.prepare.default_git_server == 'testgit':
104 # pyunit method to compare 2 str
105 self.assertEqual(OK, "OK")
107 def test_override_APPLICATION(self):
108 '''override APPLICATION
112 # The command to test
113 sat = Sat("-oAPPLICATION.out_dir='/tmp'")
114 sat.config('appli-test')
116 if sat.cfg.APPLICATION.out_dir == '/tmp':
119 # pyunit method to compare 2 str
120 self.assertEqual(OK, "OK")
122 def test_override_PRODUCTS(self):
127 # The command to test
128 sat = Sat("-oPRODUCTS.softA.name='test'")
131 if sat.cfg.PRODUCTS.softA.name == 'test':
134 # pyunit method to compare 2 str
135 self.assertEqual(OK, "OK")
138 if __name__ == '__main__':
139 HTMLTestRunner.main()