def mock_handler(http_request): """ Mock WB Provider Handler. Since tornado 5.0, handler cannot be shared between tests as fixtures when the testing tornado web server is started with ``autoreload=True``, which is enabled automatically if debug mode is on. Although setting either ``autoreload==False`` or ``Debug=False`` fixes the issue, it is still better to take this mock handler out from fixtures. :param http_request: the mocked HTTP request that is required to start the tornado web app :return: a mocked handler """ handler = ProviderHandler(make_app(True), http_request) handler.path_kwargs = {'provider': 'test', 'path': '/file', 'resource': 'guid1'} handler.path = '/test_path' handler.provider = MockProvider() handler.requested_version = None handler.resource = 'test_source_resource' handler.metadata = MockFileMetadata() handler.dest_path = '/test_dest_path' handler.dest_provider = MockProvider() handler.dest_resource = 'test_dest_resource' handler.dest_meta = MockFileMetadata() handler.arguments = {} handler.write = Mock() handler.write_stream = MockCoroutine() handler.redirect = Mock() handler.uploader = asyncio.Future() handler.wsock = Mock() handler.writer = Mock() return handler
def handler(http_request): mocked_handler = ProviderHandler(make_app(True), http_request) mocked_handler.path_kwargs = { 'provider': 'test', 'path': '/file', 'resource': 'guid1' } mocked_handler.path = '/test_path' mocked_handler.provider = MockProvider() mocked_handler.requested_version = None mocked_handler.resource = 'test_source_resource' mocked_handler.metadata = MockFileMetadata() mocked_handler.dest_path = '/test_dest_path' mocked_handler.dest_provider = MockProvider() mocked_handler.dest_resource = 'test_dest_resource' mocked_handler.dest_meta = MockFileMetadata() mocked_handler.arguments = {} mocked_handler.write = mock.Mock() mocked_handler.write_stream = MockCoroutine() mocked_handler.redirect = mock.Mock() mocked_handler.uploader = asyncio.Future() mocked_handler.wsock = mock.Mock() mocked_handler.writer = mock.Mock() return mocked_handler
def get_app(self): return make_app(debug=False)