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'))
28 sys.path.append(os.path.join(testdir, '..', '..','commands'))
32 from tools import outRedirection
34 from salomeTools import Sat
37 class TestPrepare(unittest.TestCase):
38 '''Test of the prepare command
41 def test_prepare_dev(self):
42 '''Test the prepare command with a product in dev mode
47 product_name = 'PRODUCT_DEV'
53 expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
54 expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
55 expected_text = 'HELLO WORLD\n'
57 if os.path.exists(expected_src_dir):
58 shutil.rmtree(expected_src_dir)
60 sat.prepare(appli + ' --product ' + product_name)
62 f = open(expected_file_path, 'r')
63 text = f.readlines()[0]
64 if text == expected_text:
67 # pyunit method to compare 2 str
68 self.assertEqual(OK, 'OK')
70 def test_prepare_all(self):
71 '''Test the prepare command with all products
76 product_name = 'PRODUCT_DEV'
81 expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
82 expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
83 expected_text = 'HELLO WORLD\n'
85 if os.path.exists(expected_src_dir):
86 shutil.rmtree(expected_src_dir)
90 f = open(expected_file_path, 'r')
91 text = f.readlines()[0]
92 if text == expected_text:
95 # pyunit method to compare 2 str
96 self.assertEqual(OK, 'OK')
98 def test_prepare_option_sample_and_force(self):
99 '''Test the prepare command with all products
109 sat.prepare(appli + " --no_sample --force")
114 # pyunit method to compare 2 str
115 self.assertEqual(OK, 'OK')
117 def test_description(self):
118 '''Test the sat -h prepare
125 if "The prepare command gets the sources" in prepare.description():
128 # pyunit method to compare 2 str
129 self.assertEqual(OK, "OK")
132 if __name__ == '__main__':
133 HTMLTestRunner.main()