class zzzTestFrameworkCommandHelper(unittest.TestCase): ''' Perform tests on different parts of the functionality for framework CommandHelper @param unittest.TestCase: unittest TestCase class inheritance object reference @author: ekkehard @change: Breen Malmberg - 04/11/2018 - removed assertion tests - you can't test for exception assertions in code that is wrapped by try except because the try except intercepts the exception and throws it and it never gets back to the assertraises call (see tf ticket for documentation) ''' def setUp(self): ''' ''' self.enviro = Environment() self.enviro.setdebugmode(True) self.logger = LogDispatcher(self.enviro) self.commandhelper = CommandHelper(self.logger) def tearDown(self): ''' ''' pass def testExecuteValidCommand(self): ''' ''' self.assertTrue(self.commandhelper.executeCommand("ls -l /"), "Execute Valid Command string Failed!") self.assertTrue(self.commandhelper.executeCommand(["ls", "-l", "/"]), "Execute Valid Command List Failed!") def testSetLogPriority(self): ''' ''' self.assertTrue(self.commandhelper.setLogPriority(LogPriority.INFO), "Execute setLogPriority(0) Command string Failed!") self.assertTrue(self.commandhelper.executeCommand(["ls", "-l", "/"]), "Execute commandhelper.executeCommand(['ls','-l','/'])" + " Command List Failed!")
class zzzTestFrameworkCommandHelper(unittest.TestCase): def setUp(self): self.enviro = Environment() self.enviro.setdebugmode(True) self.logger = LogDispatcher(self.enviro) self.commandhelper = CommandHelper(self.logger) def tearDown(self): pass def testBlankCommand(self): self.assertRaises(ValueError, self.commandhelper.setCommand, "") self.assertRaises(TypeError, self.commandhelper.executeCommand, None) self.assertRaises(ValueError, self.commandhelper.executeCommand, "") self.assertRaises(ValueError, self.commandhelper.setCommand, []) self.assertRaises(TypeError, self.commandhelper.executeCommand, None) self.assertRaises(ValueError, self.commandhelper.executeCommand, []) def testExecuteValidCommand(self): self.assertTrue(self.commandhelper.executeCommand("ls -l /"), "Execute Valid Command string Failed!") self.assertTrue(self.commandhelper.executeCommand(["ls", "-l", "/"]), "Execute Valid Command List Failed!") def testExecuteInvalidCommand(self): self.assertRaises(TypeError, self.commandhelper.executeCommand, 0) self.assertRaises(TypeError, self.commandhelper.executeCommand, ['ls', 0, '/']) def testSetLogPriority(self): self.assertRaises(TypeError, self.commandhelper.setLogPriority, 0) self.assertTrue(self.commandhelper.setLogPriority(LogPriority.INFO), "Execute setLogPriority(0) Command string Failed!") self.assertTrue(self.commandhelper.executeCommand(["ls", "-l", "/"]), "Execute commandhelper.executeCommand(['ls','-l','/'])" + " Command List Failed!")
class zzzTestFrameworkCommandHelper(unittest.TestCase): def setUp(self): self.enviro = Environment() self.enviro.setdebugmode(True) self.logger = LogDispatcher(self.enviro) self.commandhelper = CommandHelper(self.logger) def tearDown(self): pass def testBlankCommand(self): self.assertRaises(ValueError, self.commandhelper.setCommand, "") self.assertRaises(TypeError, self.commandhelper.executeCommand, None) self.assertRaises(ValueError, self.commandhelper.executeCommand, "") self.assertRaises(ValueError, self.commandhelper.setCommand, []) self.assertRaises(TypeError, self.commandhelper.executeCommand, None) self.assertRaises(ValueError, self.commandhelper.executeCommand, []) def testExecuteValidCommand(self): self.assertTrue(self.commandhelper.executeCommand("ls -l /"), "Execute Valid Command string Failed!") self.assertTrue(self.commandhelper.executeCommand(["ls", "-l", "/"]), "Execute Valid Command List Failed!") def testExecuteInvalidCommand(self): self.assertRaises(TypeError, self.commandhelper.executeCommand, 0) self.assertRaises(TypeError, self.commandhelper.executeCommand, ['ls', 0, '/']) def testSetLogPriority(self): self.assertRaises(TypeError, self.commandhelper.setLogPriority, 0) self.assertTrue(self.commandhelper.setLogPriority(LogPriority.INFO), "Execute setLogPriority(0) Command string Failed!") self.assertTrue( self.commandhelper.executeCommand(["ls", "-l", "/"]), "Execute commandhelper.executeCommand(['ls','-l','/'])" + " Command List Failed!")
class zzzTestFrameworkCommandHelper(unittest.TestCase): '''Perform tests on different parts of the functionality for framework CommandHelper :param unittest: TestCase: unittest TestCase class inheritance object reference @author: ekkehard @change: Breen Malmberg - 04/11/2018 - removed assertion tests - you can't test for exception assertions in code that is wrapped by try except because the try except intercepts the exception and throws it and it never gets back to the assertraises call (see tf ticket for documentation) ''' def setUp(self): ''' ''' self.enviro = Environment() self.enviro.setdebugmode(True) self.logger = LogDispatcher(self.enviro) self.commandhelper = CommandHelper(self.logger) def tearDown(self): ''' ''' pass def testExecuteValidCommand(self): ''' ''' self.assertTrue(self.commandhelper.executeCommand("ls -l /"), "Execute Valid Command string Failed!") self.assertTrue(self.commandhelper.executeCommand(["ls", "-l", "/"]), "Execute Valid Command List Failed!") def testSetLogPriority(self): ''' ''' self.assertTrue(self.commandhelper.setLogPriority(LogPriority.INFO), "Execute setLogPriority(0) Command string Failed!") self.assertTrue( self.commandhelper.executeCommand(["ls", "-l", "/"]), "Execute commandhelper.executeCommand(['ls','-l','/'])" + " Command List Failed!")