コード例 #1
0
    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"]))
コード例 #2
0
    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"]))
コード例 #3
0
    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"]))
コード例 #4
0
    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)
コード例 #5
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"]))
コード例 #6
0
    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, {}))
コード例 #7
0
    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, {}))
コード例 #8
0
    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))
コード例 #9
0
    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)
コード例 #10
0
    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))
コード例 #11
0
    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)
コード例 #12
0
    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))
コード例 #13
0
ファイル: log_2_output.py プロジェクト: deepcoder42/check-log
    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))