当前位置: 首页>>代码示例>>Python>>正文


Python DummyRequest.accept方法代码示例

本文整理汇总了Python中pyramid.testing.DummyRequest.accept方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.accept方法的具体用法?Python DummyRequest.accept怎么用?Python DummyRequest.accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.testing.DummyRequest的用法示例。


在下文中一共展示了DummyRequest.accept方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_accept_application_json

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import accept [as 别名]
 def test_accept_application_json(self):
     request = DummyRequest(path='/thing/1')
     request.accept = MIMEAccept('application/json')
     request.matchdict = {'id': 1}
     view = RESTfulView(_dummy_context_factory(), request)
     response = view.get_member()
     self.assertEqual(response.content_type, 'application/json')
     member = json.loads(response.body)['results'][0]
     self.assertEqual(member['id'], 1)
开发者ID:antonygc,项目名称:pyramid_restler,代码行数:11,代码来源:tests.py

示例2: new_request

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import accept [as 别名]
 def new_request(self, type=None):
     request = self.current_request
     auth = dict()
     if request:
         environ = request.environ
         for key in self.auth_env_keys:
             if environ.has_key(key):
                 auth[key] = environ[key]
     request = DummyRequest()
     request.environ['SERVER_NAME'] = 'testcase'
     request.environ['AUTH_TYPE'] = 'cookie'
     request.environ.update(auth)
     if type == 'json':
         request.headers['X-Request'] = 'JSON'
         request.accept = 'application/json'
     self.current_request = request
     return request
开发者ID:AnneGilles,项目名称:cone.app,代码行数:19,代码来源:testing.py

示例3: DocumentContextFactory

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import accept [as 别名]
                    # TODO: Log result if error! By John Doe
                    task_manager.on_update_progress(
                        task_id, 5.0, msg='Preparing to change column name')

                # NOTE: Get column value for each document! By John Doe
                url='/%s/doc' % (base.metadata.name)

                search_param='{"select":["id_doc", "%s"],"limit":null}' %\
                        column_path[-1]
                params={
                    '$$': search_param
                }
                request=DummyRequest(path=url, params=params)
                request.method='GET'
                request.matchdict={"base": base.metadata.name}
                request.accept=Accept("application/json")
                doc_view=DocumentCustomView(
                    DocumentContextFactory(request), 
                    request
                )
                results=doc_view.get_collection(render_to_response=True)
                results=results.json_body['results']

                if async:
                    # NOTE: Update task progress! By John Doe

                    # TODO: Log result if error! By John Doe
                    task_manager.on_update_progress(
                        task_id, 10.0, msg="Saved old documents' values")

                # NOTE: Delete old column value from documents! By John Doe
开发者ID:lightbase,项目名称:LBGenerator,代码行数:33,代码来源:base.py

示例4: test_xml_renderer

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import accept [as 别名]
 def test_xml_renderer(self):
     request = DummyRequest(path='/thing/1')
     request.accept = MIMEAccept('application/xml')
     request.matchdict = {'id': 1}
     view = RESTfulView(_dummy_context_factory(), request)
     self.assertRaises(HTTPBadRequest, view.get_member)
开发者ID:antonygc,项目名称:pyramid_restler,代码行数:8,代码来源:tests.py


注:本文中的pyramid.testing.DummyRequest.accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。