]> SALOME platform Git repositories - tools/sat.git/blob - test/test_sat5_0/prepare/test_prepare.py
Salome HOME
replace all usage of bare except clause with except Exception clause
[tools/sat.git] / test / test_sat5_0 / prepare / test_prepare.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3
4 #  Copyright (C) 2010-2018  CEA/DEN
5 #
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.
10 #
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.
15 #
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
19
20 import os
21 import sys
22 import shutil
23 import unittest
24
25 import src
26 from src.salomeTools import Sat
27
28 class TestCase(unittest.TestCase):
29     """Test of the prepare command"""
30
31     def test_010(self):
32         # Test the prepare command with a product in dev mode
33         OK = 'KO'
34
35         appli = 'appli-test'
36         product_name = 'PRODUCT_DEV'
37
38         sat = Sat()
39                
40         sat.config(appli)
41         
42         expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
43         expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
44         expected_text = 'HELLO WORLD\n'
45         
46         if os.path.exists(expected_src_dir):
47             shutil.rmtree(expected_src_dir)
48         
49         sat.prepare(appli + ' --product ' + product_name)
50         
51         f = open(expected_file_path, 'r')
52         text = f.readlines()[0]
53         if text == expected_text:
54             OK = 'OK'
55         self.assertEqual(OK, 'OK')
56
57     def test_020(self):
58         # Test the prepare command with all products
59         OK = 'KO'
60
61         appli = 'appli-test'
62         product_name = 'PRODUCT_DEV'
63
64         sat = Sat()
65         sat.config(appli)
66         
67         expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
68         expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
69         expected_text = 'HELLO WORLD\n'
70         
71         if os.path.exists(expected_src_dir):
72             shutil.rmtree(expected_src_dir)
73         
74         sat.prepare(appli)
75         
76         f = open(expected_file_path, 'r')
77         text = f.readlines()[0]
78         if text == expected_text:
79             OK = 'OK'
80         self.assertEqual(OK, 'OK')
81
82     def test_030(self):
83         # Test the prepare command with all products
84         OK = 'KO'
85
86         appli = 'appli-test'
87
88         sat = Sat()
89         sat.config(appli)
90        
91         try:
92             sat.prepare(appli + " --force --force_patch")
93             OK = 'OK'
94         except Exception:
95             pass
96         self.assertEqual(OK, 'OK')
97
98     def test_040(self):
99         # Test the sat -h prepare
100         OK = "KO"
101
102         import prepare
103         
104         if "The prepare command gets the sources" in prepare.description():
105             OK = "OK"
106         self.assertEqual(OK, "OK")
107
108 # test launch
109 if __name__ == '__main__':
110     unittest.main()
111     pass