Exemple #1
0
    def test_false_and_data_msg(self, mock_log, mock_rq):
        """Function:  test_false_and_data_msg

        Description:  Test process_msg function with status is False and error
            message.

        Arguments:

        """

        mock_log.return_value = True
        mock_rq.return_value = rmq_metadata.rabbitmq_class.RabbitMQCon
        mock_rq.create_connection.return_value = (False, "Error_Message")

        self.assertFalse(rmq_metadata.monitor_queue(self.cfg, mock_log))
Exemple #2
0
    def test_one_queue_fail(self, mock_log, mock_rq):
        """Function:  test_one_queue_fail

        Description:  Test with one queue fails to initialize.

        Arguments:

        """

        mock_log.return_value = True
        mock_rq.return_value = rmq_metadata.rabbitmq_class.RabbitMQCon
        mock_rq.create_connection.return_value = (False, "Error Message")
        mock_rq.channel.is_open = True

        self.assertFalse(rmq_metadata.monitor_queue(self.cfg, mock_log))
Exemple #3
0
    def test_true_and_false(self, mock_log, mock_rq):
        """Function:  test_true_and_false

        Description:  Test process_msg function with status is True and
            channel is False.

        Arguments:

        """

        mock_log.return_value = True
        mock_rq.return_value = rmq_metadata.rabbitmq_class.RabbitMQCon
        mock_rq.create_connection.return_value = (True, "Error_Message")
        mock_rq.channel.is_open = False

        self.assertFalse(rmq_metadata.monitor_queue(self.cfg, mock_log))
Exemple #4
0
    def test_one_queue_success(self, mock_log, mock_rq):
        """Function:  test_one_queue_success

        Description:  Test with one queue initialized and monitored.

        Arguments:

        """

        mock_log.return_value = True
        mock_rq.return_value = rmq_metadata.rabbitmq_class.RabbitMQCon
        mock_rq.create_connection.return_value = (True, "")
        mock_rq.channel.is_open = True
        mock_rq.consume.return_value = "RabbitMQ_Tag"
        mock_rq.start_loop.return_value = True

        self.assertFalse(rmq_metadata.monitor_queue(self.cfg, mock_log))
Exemple #5
0
    def test_two_queue_partial(self, mock_log, mock_rq):
        """Function:  test_two_queue_partial

        Description:  Test with two queues with one queue failure.

        Arguments:

        """

        mock_log.return_value = True
        mock_rq.return_value = rmq_metadata.rabbitmq_class.RabbitMQCon
        mock_rq.create_connection.side_effect = [(True, ""), (False, "Error")]
        mock_rq.channel.is_open.side_effect = [True, False]
        mock_rq.consume.return_value = "RabbitMQ_Tag"
        mock_rq.start_loop.return_value = True

        self.assertFalse(rmq_metadata.monitor_queue(self.cfg, mock_log))