def test_publish_main_unexpected_error( self, mock_exit, mock_publish_service, mock_config ): mock_publish_service.side_effect = Exception('Error!') main() mock_exit.assert_called_once_with(1)
def test_publish_main_system_exit( self, mock_exit, mock_publish_service, mock_config ): mock_publish_service.side_effect = SystemExit() main() mock_exit.assert_called_once_with(0)
def test_publish_main( self, mock_publish_service, mock_config, mock_factory ): config = Mock() config.get_publish_thread_pool_count.return_value = 50 mock_config.return_value = config factory = Mock() mock_factory.return_value = factory main() mock_publish_service.assert_called_once_with( service_exchange='publish', config=config, custom_args={ 'job_factory': factory, 'thread_pool_count': 50 } )
def test_publish_main_mash_error( self, mock_exit, mock_publish_service, mock_config, mock_factory ): config = Mock() config.get_publish_thread_pool_count.return_value = 50 mock_config.return_value = config mock_publish_service.side_effect = MashPublishException('error') factory = Mock() mock_factory.return_value = factory main() mock_publish_service.assert_called_once_with( service_exchange='publish', config=config, custom_args={ 'job_factory': factory, 'thread_pool_count': 50 } ) mock_exit.assert_called_once_with(1)
def test_main_keyboard_interrupt( self, mock_exit, mock_publish_service, mock_config ): mock_publish_service.side_effect = KeyboardInterrupt main() mock_exit.assert_called_once_with(0)