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 salomeTools import Sat
35 class TestPrepare(unittest.TestCase):
36 '''Test of the prepare command
39 def test_prepare_dev(self):
40 '''Test the prepare command with a product in dev mode
45 product_name = 'PRODUCT_DEV'
51 expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
52 expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
53 expected_text = 'HELLO WORLD\n'
55 if os.path.exists(expected_src_dir):
56 shutil.rmtree(expected_src_dir)
58 sat.prepare(appli + ' --product ' + product_name)
60 f = open(expected_file_path, 'r')
61 text = f.readlines()[0]
62 if text == expected_text:
65 # pyunit method to compare 2 str
66 self.assertEqual(OK, 'OK')
68 def test_prepare_all(self):
69 '''Test the prepare command with all products
74 product_name = 'PRODUCT_DEV'
79 expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
80 expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
81 expected_text = 'HELLO WORLD\n'
83 if os.path.exists(expected_src_dir):
84 shutil.rmtree(expected_src_dir)
88 f = open(expected_file_path, 'r')
89 text = f.readlines()[0]
90 if text == expected_text:
93 # pyunit method to compare 2 str
94 self.assertEqual(OK, 'OK')
96 def test_prepare_option_sample_and_force(self):
97 '''Test the prepare command with all products
107 sat.prepare(appli + " --force --force_patch")
112 # pyunit method to compare 2 str
113 self.assertEqual(OK, 'OK')
115 def test_description(self):
116 '''Test the sat -h prepare
123 if "The prepare command gets the sources" in prepare.description():
126 # pyunit method to compare 2 str
127 self.assertEqual(OK, "OK")
130 if __name__ == '__main__':
131 HTMLTestRunner.main()