Example #1
0
 def test_main(self, mock_init, mock_connect, mock_reduce, _):
     """
     Test: A QueueClient is initialised and connected and ppa.reduce is called
     When: The main method is called
     """
     sys.argv = ['', '/queue/ReductionPending', json.dumps(self.data)]
     main()
     mock_init.assert_called_once()
     mock_connect.assert_called_once()
     mock_reduce.assert_called_once()
Example #2
0
 def test_main_inner_exception(self, mock_client_init, mock_connect, mock_send, mock_ppa_init,
                               mock_logger, mock_exit):
     """
     Test: The correct message is sent from the exception handlers in main
     When: A bare Exception is raised from ppa.reduce
     """
     def raise_exception(arg1, _):
         """Raise Exception"""
         self.assertEqual(arg1, self.message)
         raise Exception('error-message')
     mock_ppa_init.side_effect = raise_exception
     sys.argv = ['', '/queue/ReductionPending', json.dumps(self.data)]
     main()
     mock_connect.assert_called_once()
     mock_client_init.assert_called_once()
     mock_logger.assert_has_calls([call('PostProcessAdmin error: %s', 'error-message')])
     mock_exit.assert_called_once()
     mock_send.assert_called_once_with(ACTIVEMQ_SETTINGS.reduction_error,
                                       self.message)