4 # Copyright (C) 2010-2018 CEA/DEN
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.
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.
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
24 import initializeTest # set PATH etc for test
26 import src.salomeTools as SAT
27 import src.debug as DBG # Easy print stderr (for DEBUG only)
28 import src.loggingSimple as LOG
30 class TestCase(unittest.TestCase):
31 "Test the sat --help commands"""
36 # print "tearDown", __file__
37 # assure self.logger clear for next test
38 logger = LOG.getUnittestLogger()
39 logs = logger.getLogsAndClear()
40 # using assertNotIn() is too much verbose
41 self.assertFalse("ERROR" in logs)
42 self.assertFalse("CRITICAL" in logs)
45 logger = LOG.getUnittestLogger()
46 # one shot setUp() for this TestCase
47 if self.debug: DBG.push_debug(True)
48 SAT.setNotLocale() # test english
51 # one shot tearDown() for this TestCase
52 SAT.setLocale() # end test english
53 if self.debug: DBG.pop_debug()
55 def test_010(self): # TODO fix logger unittest
57 res = SAT.launchSat(cmd)
58 self.assertTrue(res.isOk())
60 self.assertTrue(" - config" in out)
61 self.assertTrue(" - prepare" in out)
62 self.assertTrue(" - compile" in out)
65 logger = LOG.getUnittestLogger()
68 returnCode = s.execute_cli(cmd)
69 self.assertTrue(returnCode.isOk())
70 logs = logger.getLogs()
71 DBG.write("test_011 logger", logs)
72 self.assertTrue(" - config" in logs)
73 self.assertTrue(" - prepare" in logs)
74 self.assertTrue(" - compile" in logs)
77 cmd = "sat config --help"
78 returnCode = SAT.launchSat(cmd)
79 self.assertTrue(returnCode.isOk())
80 out = returnCode.getValue()
81 DBG.write("test_030 stdout", out)
82 self.assertTrue("--value" in out)
85 logger = LOG.getUnittestLogger()
88 returnCode = s.execute_cli(cmd)
89 self.assertTrue(returnCode.isOk())
90 logs = logger.getLogs()
91 DBG.write("test_031 logger", logs)
92 self.assertTrue("--help" in logs)
95 logger = LOG.getUnittestLogger()
96 cmd = "prepare --help"
98 returnCode = s.execute_cli(cmd)
99 self.assertTrue(returnCode.isOk())
100 logs = logger.getLogs()
101 DBG.write("test_031 logger", logs)
102 self.assertTrue("--help" in logs)
105 logger = LOG.getUnittestLogger()
106 cmd = "config --list"
108 returnCode = s.execute_cli(cmd)
109 self.assertTrue(returnCode.isOk())
110 logs = logger.getLogs()
111 self.assertTrue("Applications" in logs)
114 cmds = SAT.getCommandsList()
115 DBG.write("test_050 getCommandsList", cmds)
117 cmd = "sat %s --help" % c
118 DBG.write("test_050", cmd)
119 returnCode = SAT.launchSat(cmd)
120 if not returnCode.isOk():
121 DBG.write("test_050 %s" % cmd, returnCode.getValue(), True)
122 self.assertTrue(returnCode.isOk())
123 out = returnCode.getValue()
124 DBG.write("test_050 %s stdout" % c, out)
125 self.assertTrue("The %s command" % c in out)
126 self.assertTrue("Available options" in out)
129 logger = LOG.getUnittestLogger()
130 cmds = SAT.getCommandsList()
132 cmd = "%s --help" % c
133 DBG.write("test_051", cmd)
135 returnCode = s.execute_cli(cmd)
136 self.assertTrue(returnCode.isOk())
137 logs = logger.getLogsAndClear()
139 self.assertTrue("The %s command" % c in logs)
140 self.assertTrue("Available options" in logs)
142 if __name__ == '__main__':
143 unittest.main(exit=False)