def test_w_option_data_log(self): """Function: test_w_option_data_log Description: Test with -w option and data log. Arguments: """ check_log.log_2_output(self.log, self.args_array2) self.assertTrue(os.path.isfile(self.args_array2["-o"]))
def test_w_option_empty_log(self): """Function: test_w_option_empty_log Description: Test with -w option and empty log. Arguments: """ self.log.loglist = [] check_log.log_2_output(self.log, self.args_array2) self.assertFalse(os.path.isfile(self.args_array2["-o"]))
def test_write_to_log(self): """Function: test_write_to_log Description: Test writing data to log. Arguments: """ with gen_libs.no_std_out(): check_log.log_2_output(self.log, self.args_array) self.assertTrue(os.path.isfile(self.args_array["-o"]))
def test_write_to_log_empty_log(self): """Function: test_write_to_log_empty_log Description: Test writing data to log and empty log. Arguments: """ self.log.loglist = [] check_log.log_2_output(self.log, self.args_array) self.assertTrue( os.path.isfile(self.args_array["-o"]) and os.stat(self.args_array["-o"]).st_size == 0)
def test_t_o_options_set(self, mock_mail): """Function: test_t_o_options_set Description: Test with -t and -o options set. Arguments: """ mock_mail.send_mail.return_value = True self.args_array["-t"] = self.msg with gen_libs.no_std_out(): check_log.log_2_output(self.log, self.args_array) self.assertTrue(os.path.isfile(self.args_array["-o"]))
def test_o_option_not_set(self): """Function: test_o_option_not_set Description: Test with -o option not set. Arguments: """ with gen_libs.no_std_out(): self.assertFalse(check_log.log_2_output(self.log, {}))
def test_o_option_empty_log(self): """Function: test_o_option_empty_log Description: Test with -o option and empty log. Arguments: """ self.log.loglist = [] self.assertFalse(check_log.log_2_output(self.log, {}))
def test_z_option_set(self): """Function: test_z_option_set Description: Test with -z option set. Arguments: """ self.args_array = {"-z": True} self.assertFalse(check_log.log_2_output(self.log, self.args_array))
def test_g_option_write(self): """Function: test_g_option_write Description: Test with -g option with write value. Arguments: """ self.log.loglist = [self.line1] check_log.log_2_output(self.log, self.args_array4) self.log.loglist = [self.line2] check_log.log_2_output(self.log, self.args_array4) if os.path.isfile(self.args_array4["-o"]): with open(self.args_array4["-o"]) as f_hdlr: out_str = f_hdlr.readline().rstrip() self.assertEqual(out_str, self.line2) else: self.assertTrue(False)
def test_t_z_options_set(self, mock_mail): """Function: test_t_z_options_set Description: Test with -t and -z options set. Arguments: """ mock_mail.send_mail.return_value = True self.args_array = {"-t": self.msg, "-z": True} self.assertFalse(check_log.log_2_output(self.log, self.args_array))
def test_g_option_append(self): """Function: test_g_option_append Description: Test with -g option with append value. Arguments: """ self.log.loglist = [self.line1] check_log.log_2_output(self.log, self.args_array3) self.log.loglist = [self.line2] check_log.log_2_output(self.log, self.args_array3) if os.path.isfile(self.args_array3["-o"]): with open(self.args_array3["-o"]) as f_hdlr: out_str = f_hdlr.read().rstrip() self.assertEqual(out_str, "first line of log\nsecond line of log") else: self.assertTrue(False)
def test_t_option_set(self, mock_mail): """Function: test_t_option_set Description: Test with -t option set. Arguments: """ mock_mail.send_mail.return_value = True self.args_array = {"-t": self.msg} with gen_libs.no_std_out(): self.assertFalse(check_log.log_2_output(self.log, self.args_array))
def test_mail(self, mock_mail): """Function: test_mail Description: Test sending via mail. Arguments: """ mock_mail.return_value = True self.args_array = {"-t": "*****@*****.**", "-z": True} self.assertFalse(check_log.log_2_output(self.log, self.args_array))