Пример #1
0
 def _make_lti11_mock_request_handler(
     handler: RequestHandler,
     uri: str = "https://hub.example.com",
     method: str = "POST",
     **settings: dict,
 ) -> RequestHandler:
     """Instantiate a Handler in a mock application"""
     application = Application(
         hub=Mock(
             base_url="/hub/",
             server=Mock(base_url="/hub/"),
         ),
         cookie_secret=os.urandom(32),
         db=Mock(rollback=Mock(return_value=None)),
         **settings,
     )
     request = HTTPServerRequest(
         method=method,
         uri=uri,
         connection=Mock(),
     )
     handler = RequestHandler(
         application=application,
         request=request,
     )
     handler._transforms = []
     return handler
Пример #2
0
    def _make_mock_request_handler(
        handler: RequestHandler,
        uri: str = 'https://hub.example.com',
        method: str = 'GET',
        **settings: dict,
    ) -> RequestHandler:
        '''Instantiate a Handler in a mock application'''

        application = Application(
            hub=Mock(base_url='/hub/', server=Mock(base_url='/hub/')),
            cookie_secret=os.urandom(32),
            db=Mock(rollback=Mock(return_value=None)),
            **settings,
        )

        request = HTTPServerRequest(method=method, uri=uri, connection=Mock())

        handler = RequestHandler(application=application, request=request)

        handler._transforms = []

        return handler