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


Python DummyRequest.method方法代码示例

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


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

示例1: test_request_method_sequence

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
 def test_request_method_sequence(self):
     _, predicates, _ = self._callFUT(request_method=("GET", "HEAD"))
     request = DummyRequest()
     request.method = "HEAD"
     self.assertTrue(predicates[0](Dummy(), request))
     request.method = "GET"
     self.assertTrue(predicates[0](Dummy(), request))
     request.method = "POST"
     self.assertFalse(predicates[0](Dummy(), request))
开发者ID:,项目名称:,代码行数:11,代码来源:

示例2: _undo_delete_column

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
    def _undo_delete_column(self, base, old_name, path, results):
        for doc in results:
            if doc.get(old_name, None):
                id_doc=doc['_metadata']['id_doc']

                url='/%s/doc/%d/%s' % (
                    base.metadata.name, 
                    id_doc, "/".join(path)
                )
                params={
                    'value': doc[old_name], 
                    'alter_files': False
                }
                request=DummyRequest(path=url, params=params)
                request.method='PUT'
                request.matchdict={
                    'base': base.metadata.name,
                    'id': str(id_doc),
                    'path': "/".join(path)
                }
                doc_view=DocumentCustomView(
                    DocumentContextFactory(request), 
                    request
                )
                response=doc_view.put_path()
开发者ID:lightbase,项目名称:LBGenerator,代码行数:27,代码来源:base.py

示例3: test_create_update

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
    def test_create_update(self):
        from papyrus.protocol import Protocol
        from pyramid.testing import DummyRequest
        from geojson import Feature, FeatureCollection
        from shapely.geometry import Point

        MappedClass = self._get_mapped_class()

        # a mock session specific to this test
        class MockSession(object):
            def query(self, mapped_class):
                return {'a': mapped_class(Feature(id='a')),
                        'b': mapped_class(Feature(id='b'))}

            def flush(self):
                pass

        proto = Protocol(MockSession, MappedClass, 'geom')

        # we need an actual Request object here, for body to do its job
        request = DummyRequest({})
        request.method = 'POST'
        request.body = '{"type": "FeatureCollection", "features": [{"type": "Feature", "id": "a", "properties": {"text": "foo"}, "geometry": {"type": "Point", "coordinates": [45, 5]}}, {"type": "Feature", "id": "b", "properties": {"text": "bar"}, "geometry": {"type": "Point", "coordinates": [46, 6]}}]}'  # NOQA
        features = proto.create(request)

        self.assertTrue(isinstance(features, FeatureCollection))
        self.assertEqual(len(features.features), 2)
        self.assertEqual(features.features[0].id, 'a')
        self.assertEqual(features.features[0].text, 'foo')
        self.assertTrue(features.features[0].geom.shape.equals(Point(45, 5)))
        self.assertEqual(features.features[1].id, 'b')
        self.assertEqual(features.features[1].text, 'bar')
        self.assertTrue(features.features[1].geom.shape.equals(Point(46, 6)))
开发者ID:gberaudo,项目名称:papyrus,代码行数:35,代码来源:test_protocol.py

示例4: test_people_profile_view

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
    def test_people_profile_view(self):
        from notaliens.people.views import people_profile_view

        request = DummyRequest()
        request.method = 'GET'
        request.db_session = mock.Mock()
        request.matchdict = mock.MagicMock()

        request.search_settings = {
            'enabled': True
        }

        user = mock.Mock()
        region = mock.Mock()
        users = mock.MagicMock()

        with mock.patch('notaliens.people.views.get_user_by_username') as get_user_by_username:  # nopep8
            with mock.patch('notaliens.people.views.get_region_by_postal') as get_region_by_postal:  # nopep8
                with mock.patch('notaliens.people.views.get_users') as get_users:  # nopep8
                    get_user_by_username.return_value = user
                    get_region_by_postal.return_value = region
                    get_users.return_value = users

                    response = people_profile_view(request)

                    assert response['data']['user'] == user
开发者ID:einSelbst,项目名称:notaliens.com,代码行数:28,代码来源:test_people_views.py

示例5: test_base_handler_dispatch

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
    def test_base_handler_dispatch(self):
        from .views import BaseHandler

        request = DummyRequest()

        for method in self.HTTP_METHODS:
            request.method = method
            instance = BaseHandler(request)
            self.assertRaises(HTTPMethodNotAllowed, instance.__call__)
开发者ID:kipanshi,项目名称:pyramid-upwork,代码行数:11,代码来源:tests.py

示例6: test_404

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
 def test_404(self, get_model):
     """ If model is not found, raise 404 """
     resource = IModelResource()
     request = DummyRequest()
     request.method = 'GET'
     resource.request = request
     get_model.return_value = None
     with self.assertRaises(HTTPNotFound):
         resource['foobar']
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:11,代码来源:test_route.py

示例7: dummy_post

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
def dummy_post(dbtransaction):
    from pyramid.testing import DummyRequest
    from webob.multidict import MultiDict
    req = DummyRequest()
    req.method = 'POST'
    md = MultiDict()
    md.add('title', 'dummy title')
    md.add('text', 'dummy text')
    req.POST = md
    return req
开发者ID:wohlfea,项目名称:learning_journal,代码行数:12,代码来源:conftest.py

示例8: _get_context

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
    def _get_context(self, method="POST"):
        from ..model.context.file import FileContextFactory
        from pyramid.testing import DummyRequest

        dummy_path="/%s/file/" % (self.params['basename'])
        dummy_request=DummyRequest(path=dummy_path)
        dummy_request.method=method
        dummy_request.matchdict={ "base": self.params['basename'] }
        context=FileContextFactory(dummy_request)

        return context
开发者ID:lightbase,项目名称:LBGenerator,代码行数:13,代码来源:operations.py

示例9: test_method_type

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
    def test_method_type(self):
        from pyramid_sockjs.websocket import init_websocket

        request = DummyRequest(
            environ={'HTTP_UPGRADE': 'websocket',
                     'HTTP_CONNECTION': 'keep-alive, upgrade',
                     'HTTP_SEC_WEBSOCKET_VERSION': '8'})
        request.method = 'POST'

        res = init_websocket(request)
        self.assertIsInstance(res, Response)
        self.assertEqual(res.status, '405 Method Not Allowed')
开发者ID:Bleno,项目名称:pyramid_sockjs,代码行数:14,代码来源:test_websocket.py

示例10: test_no_name_param

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
    def test_no_name_param(self):
        from pyramid.testing import DummyRequest
        from pyramid.httpexceptions import HTTPBadRequest
        from c2cgeoportal.views.export import exportgpxkml

        request = DummyRequest()
        request.method = "POST"
        request.params = {
            "format": "gpx",
            "doc": u"<gpx>éç</gpx>",
        }
        response = exportgpxkml(request)
        self.assertEqual(type(response), HTTPBadRequest)
开发者ID:eleu,项目名称:c2cgeoportal,代码行数:15,代码来源:test_export.py

示例11: test_protocol_version

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
    def test_protocol_version(self):
        from pyramid_sockjs.websocket import init_websocket

        request = DummyRequest(
            environ={'HTTP_UPGRADE': 'websocket',
                     'HTTP_CONNECTION': 'keep-alive, upgrade',
                     'HTTP_SEC_WEBSOCKET_VERSION': '8',
                     'SERVER_PROTOCOL': 'HTTP/1.0'})
        request.method = 'GET'

        res = init_websocket(request)
        self.assertIsInstance(res, HTTPBadRequest)
        self.assertEqual(res.detail, 'HTTP/1.1 is required')
开发者ID:Bleno,项目名称:pyramid_sockjs,代码行数:15,代码来源:test_websocket.py

示例12: test_registration_does_not_autologin

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
def test_registration_does_not_autologin(config, authn_policy):
    configure(config)

    request = DummyRequest()
    request.method = 'POST'
    request.POST.update({'email': '[email protected]',
                         'password': 'secret',
                         'username': 'giraffe'})

    ctrl = RegisterController(request)
    ctrl.register()

    assert not authn_policy.remember.called
开发者ID:klrkdekira,项目名称:h,代码行数:15,代码来源:views_test.py

示例13: dummy_post_request

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
def dummy_post_request():
    """Make a Dummy Request that will mimic a POST method request"""
    req = DummyRequest()
    config = setUp()
    config.add_route('add', '/compose')
    config.add_route('detail', '/entries/{entry_id}')
    config.add_route('edit', '/edit/{entry_id}')
    config.add_route('entry', '/entries/{entry_id}')
    req.method = 'POST'
    test_dict = [('title', 'test title'), ('text', 'test text')]
    mdict = multidict.MultiDict(test_dict)
    req.POST = mdict
    return req
开发者ID:ptrompeter,项目名称:learning-journal,代码行数:15,代码来源:conftest.py

示例14: test_gevent_wsgi_input

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
    def test_gevent_wsgi_input(self):
        from pyramid_sockjs.websocket import init_websocket

        request = DummyRequest(
            environ={'HTTP_UPGRADE': 'websocket',
                     'HTTP_SEC_WEBSOCKET_VERSION': '8',
                     'SERVER_PROTOCOL': 'HTTP/1.1',
                     'HTTP_SEC_WEBSOCKET_KEY': '5Jfbk3Hf5oLcReU416OxpA==',
                     'HTTP_CONNECTION': 'keep-alive, upgrade'})
        request.method = 'GET'

        res = init_websocket(request)
        self.assertIsInstance(res, HTTPBadRequest)
        self.assertEqual(res.detail, "socket object is not available")
开发者ID:Bleno,项目名称:pyramid_sockjs,代码行数:16,代码来源:test_websocket.py

示例15: test_put_create

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import method [as 别名]
 def test_put_create(self, get_model, create_model):
     """ Put request can create a new model """
     resource = IModelResource()
     request = DummyRequest()
     request.method = 'PUT'
     resource.request = request
     get_model.return_value = None
     ret = resource['foobar']
     self.assertTrue(isinstance(ret, IModelResource))
     self.assertEqual(ret.__parent__, resource)
     self.assertEqual(ret.__name__, 'foobar')
     get_model.assert_called_with('foobar')
     create_model.assert_called_with('foobar')
     self.assertEqual(ret.model, create_model())
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:16,代码来源:test_route.py


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