Salome HOME
Merge branch 'BR_8_3' of https://codev-tuleap.cea.fr/plugins/git/spns/SAT into BR_8_3
[tools/sat.git] / test / config / create_user_pyconf.py
index 4b5a256feed8e95714ff30474db9afc644ed0ae2..6036d301502d77a73e2796ecf5a4b9aca350e9da 100644 (file)
@@ -23,30 +23,32 @@ import shutil
 
 # get execution path
 testdir = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(os.path.join(testdir, '..', '..', 'src'))
-sys.path.append(os.path.join(testdir, '..', '..', 'test', '_testTools'))
+sys.path.append(os.path.join(testdir, '..', '..'))
+sys.path.append(os.path.join(testdir, '..', '_testTools'))
 
-from salomeTools import salomeTools
+from salomeTools import Sat
 import HTMLTestRunner
 
 class TestConfig(unittest.TestCase):
     '''pyunit class : each method execute one test.
     '''
     
-    def test_option_value(self):
-        '''Test the display of the right value of "sat config -v VARS.hostname"
+    def test_user_dir_creation(self):
+        '''Creation of ~/.salomeTools/salomeTools.pyconf
         '''
         res = "KO"
         user_dir = os.path.expanduser(os.path.join('~','.salomeTools'))
         user_dir_save = os.path.expanduser(os.path.join('~','.salomeTools_save'))
+        if os.path.exists(user_dir_save):
+            shutil.rmtree(user_dir_save)
         if os.path.exists(user_dir):
             shutil.move(user_dir, user_dir_save)
                
         # The command to test
-        sat = salomeTools('')
+        sat = Sat('')
         sat.config('-v .')
 
-        expected_file = os.path.expanduser(os.path.join('~','.salomeTools', 'salomeTools-' + sat.cfg.INTERNAL.sat_version + ".pyconf"))
+        expected_file = os.path.expanduser(os.path.join('~','.salomeTools', 'salomeTools.pyconf'))
 
         if os.path.exists(expected_file):
             res = "OK"
@@ -57,6 +59,83 @@ class TestConfig(unittest.TestCase):
         # pyunit method to compare 2 str
         self.assertEqual(res, "OK")
 
+    def test_override_VARS(self):
+        '''override VARS
+        '''
+        OK = "KO"
+        
+        # The command to test
+        sat = Sat("-oVARS.user='user_test'")
+        sat.config()
+
+        if sat.cfg.VARS.user == 'user_test':
+            OK = "OK"
+
+        # pyunit method to compare 2 str
+        self.assertEqual(OK, "OK")
+
+    def test_override_INTERNAL(self):
+        '''override INTERNAL
+        '''
+        OK = "KO"
+        
+        # The command to test
+        sat = Sat("-oINTERNAL.sat_version='V0'")
+        sat.config()
+
+        if sat.cfg.INTERNAL.sat_version == 'V0':
+            OK = "OK"
+
+        # pyunit method to compare 2 str
+        self.assertEqual(OK, "OK")
+
+    """
+    def test_override_SITE(self):
+        '''override SITE
+        '''
+        OK = "KO"
+        
+        # The command to test
+        sat = Sat("-oSITE.jobs.config_path='/tmp'")
+        sat.config()
+
+        if sat.cfg.SITE.jobs.config_path == '/tmp':
+            OK = "OK"
+
+        # pyunit method to compare 2 str
+        self.assertEqual(OK, "OK")
+    """
+
+    def test_override_APPLICATION(self):
+        '''override APPLICATION
+        '''
+        OK = "KO"
+        
+        # The command to test
+        sat = Sat("-oAPPLICATION.out_dir='/tmp'")
+        sat.config('appli-test')
+
+        if sat.cfg.APPLICATION.out_dir == '/tmp':
+            OK = "OK"
+
+        # pyunit method to compare 2 str
+        self.assertEqual(OK, "OK")
+
+    def test_override_PRODUCTS(self):
+        '''override PRODUCTS
+        '''
+        OK = "KO"
+        
+        # The command to test
+        sat = Sat("-oPRODUCTS.PRODUCT_GIT.default.name='test'")
+        sat.config('')
+
+        if sat.cfg.PRODUCTS.PRODUCT_GIT.default.name == 'test':
+            OK = "OK"
+
+        # pyunit method to compare 2 str
+        self.assertEqual(OK, "OK")
+
 # test launch
 if __name__ == '__main__':
     HTMLTestRunner.main()