Beispiel #1
0
    def test_body_dict_true(self):
        """Function:  test_body_dict_true

        Description:  Test of json.loads function.

        Arguments:

        """

        rmq_2_sysmon.process_msg(self.rmq, self.log, self.cfg, self.method,
                                 self.body)
        self.log.log_close()

        self.assertTrue(self.log_chk in open(self.cfg.log_file).read() and \
                        os.path.isfile(self.sysmon_file))
Beispiel #2
0
    def test_non_proc_msg(self, mock_mail):
        """Function:  test_non_proc_msg

        Description:  Test of non_proc_msg function call.

        Arguments:

        """

        mock_mail.send_mail.return_value = True
        rmq_2_sysmon.process_msg(self.rmq, self.log, self.cfg, self.method,
                                 self.body2)
        self.log.log_close()

        self.assertTrue(self.non_proc_msg in open(self.cfg.log_file).read())
Beispiel #3
0
    def test_is_dict(self, mock_json, mock_log):
        """Function:  test_is_dict

        Description:  Test if the body is a dictionary.

        Arguments:

        """

        mock_json.return_value = self.body
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg, self.method,
                                     self.body))
Beispiel #4
0
    def test_create_json(self, mock_json, mock_log):
        """Function:  test_create_json

        Description:  Test if the body is converted to JSON.

        Arguments:

        """

        mock_json.return_value = self.body
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg, self.method,
                                     self.body))
Beispiel #5
0
    def test_dict_convert_fails(self, mock_msg, mock_log):
        """Function:  test_dict_convert_fails

        Description:  Test with ast.literal_eval fails for dict.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg, self.method,
                                     self.body2))
Beispiel #6
0
    def test_convert_fails_type_pass(self, mock_msg, mock_log):
        """Function:  test_convert_fails_type_pass

        Description:  Test literal_eval fails for string, but passes for type.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg3,
                                     self.method, self.body3))
Beispiel #7
0
    def test_str_convert_pass(self, mock_msg, mock_log):
        """Function:  test_str_convert_pass

        Description:  Test with ast.literal_eval pass for string.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg, self.method,
                                     self.rawbody3))
Beispiel #8
0
    def test_list_pass(self, mock_msg, mock_log):
        """Function:  test_list_pass

        Description:  Test with list passed.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg2,
                                     self.method, self.rawbody4))
Beispiel #9
0
    def test_any_pass(self, mock_msg, mock_log):
        """Function:  test_any_pass

        Description:  Test with any set for message type.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg4,
                                     self.method, self.rawbody3))
Beispiel #10
0
    def test_no_dict_key_pass(self, mock_msg, mock_log):
        """Function:  test_no_dict_key_pass

        Description:  Test with no dictionary key in dictionary.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg, self.method,
                                     self.rawbody2))
Beispiel #11
0
    def test_no_dict_key_set(self, mock_msg, mock_log):
        """Function:  test_no_dict_key_set

        Description:  Test with dict_key not set.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg5,
                                     self.method, self.rawbody))
Beispiel #12
0
    def test_flatten_true(self, mock_msg, mock_log):
        """Function:  test_flatten_true

        Description:  Test with flatten set to True.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg, self.method,
                                     self.rawbody))
Beispiel #13
0
    def test_no_prename(self, mock_msg, mock_log):
        """Function:  test_no_prename

        Description:  Test with no prename set.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg10,
                                     self.method, self.rawbody))
Beispiel #14
0
    def test_default_name(self, mock_msg, mock_log):
        """Function:  test_default_name

        Description:  Test for default file name.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg12,
                                     self.method, self.rawbody))
Beispiel #15
0
    def test_no_routing_key(self, mock_msg, mock_log):
        """Function:  test_no_routing_key

        Description:  Test with no routing key detected.

        Arguments:

        """

        mock_msg.return_value = True
        mock_log.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg13,
                                     self.method, self.rawbody))
Beispiel #16
0
    def test_key_not_in_dict(self, mock_json, mock_log, mock_msg):
        """Function:  test_key_not_in_dict

        Description:  Test with no dictionary key found.

        Arguments:

        """

        mock_json.return_value = self.body2
        mock_log.return_value = True
        mock_msg.return_value = True

        self.assertFalse(
            rmq_2_sysmon.process_msg(self.rmq, mock_log, self.cfg, self.method,
                                     self.body2))