def test_with_handler(self, mocker, pipeline, method_request):
        # Set the handler
        mock_handler = mocker.MagicMock()
        pipeline.on_method_request_received = mock_handler
        assert mock_handler.call_count == 0

        # Create the event
        method_request_event = pipeline_events_iothub.MethodRequestEvent(method_request)

        # Trigger the event
        pipeline._pipeline.on_pipeline_event_handler(method_request_event)

        assert mock_handler.call_count == 1
        assert mock_handler.call_args == mocker.call(method_request)
 def test_no_handler(self, pipeline, method_request):
     method_request_event = pipeline_events_iothub.MethodRequestEvent(
         method_request)
     pipeline._pipeline.on_pipeline_event_handler(method_request_event)