def test_run_program(self, mock_consume, mock_cfg, mock_base): """Function: test_run_program Description: Test of test_run_program function. Arguments: """ mock_consume.return_value = "RabbitMQ_Tag" mock_cfg.return_value = self.cfg mock_base.return_value = self.test_path rmq_2_sysmon.run_program(self.args_array, self.func_dict) self.assertTrue(self.connect_true in open(self.cfg.log_file).read())
def test_status_false(self, mock_log, mock_load, mock_valid): """Function: test_status_false Description: Test run_program function with status is False. Arguments: """ mock_log.return_value = True mock_load.return_value = self.cfg mock_valid.return_value = (self.cfg, False, "Failed to load cfg") with gen_libs.no_std_out(): self.assertFalse(rmq_2_sysmon.run_program(self.args, self.func_dict))
def test_raise_exception(self, mock_lock, mock_load, mock_valid, mock_log): """Function: test_raise_exception Description: Test run_program function with raising the exception. Arguments: """ mock_lock.side_effect = rmq_2_sysmon.gen_class.SingleInstanceException mock_log.return_value = rmq_2_sysmon.gen_class.Logger mock_log.log_info.return_value = True mock_log.log_close.return_value = True mock_load.return_value = self.cfg mock_valid.return_value = (self.cfg, True, "") self.assertFalse(rmq_2_sysmon.run_program(self.args, self.func_dict))
def test_func_call(self, mock_class, mock_load, mock_valid, mock_func): """Function: test_func_call Description: Test run_program function with call to function. Arguments: """ mock_class.Logger.return_value = rmq_2_sysmon.gen_class.Logger mock_load.return_value = self.cfg mock_valid.return_value = (self.cfg, True, "") mock_class.Logger.log_close.return_value = True mock_class.ProgramLock.return_value = self.proglock mock_func.return_value = True self.assertFalse(rmq_2_sysmon.run_program(self.args, self.func_dict))
def test_status_true(self, mock_log, mock_load, mock_valid): """Function: test_status_true Description: Test run_program function with status is True. Arguments: """ mock_log.return_value = rmq_2_sysmon.gen_class.Logger mock_load.return_value = self.cfg mock_valid.return_value = (self.cfg, True, "") mock_log.log_close.return_value = True # Remove to skip "for" loop. self.args.pop("-M") self.assertFalse(rmq_2_sysmon.run_program(self.args, self.func_dict))