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


Python Protocol.read方法代码示例

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


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

示例1: test_read_notfound

# 需要导入模块: from papyrus.protocol import Protocol [as 别名]
# 或者: from papyrus.protocol.Protocol import read [as 别名]
    def test_read_notfound(self):
        from papyrus.protocol import Protocol
        from pyramid.httpexceptions import HTTPNotFound

        class Session(object):
            def query(self, mapped_class):
                return {'a': None}

        proto = Protocol(Session, self._get_mapped_class(), 'geom')
        request = testing.DummyRequest()

        resp = proto.read(request, id='a')
        self.assertTrue(isinstance(resp, HTTPNotFound))
开发者ID:gberaudo,项目名称:papyrus,代码行数:15,代码来源:test_protocol.py

示例2: test_read_id

# 需要导入模块: from papyrus.protocol import Protocol [as 别名]
# 或者: from papyrus.protocol.Protocol import read [as 别名]
    def test_read_id(self):
        from papyrus.protocol import Protocol
        from shapely.geometry import Point
        from geojson import Feature

        class Session(object):
            def query(self, mapped_class):
                feature = Feature(id='a', geometry=Point(1, 2),
                                  properties=dict(text='foo'))
                return {'a': mapped_class(feature)}

        proto = Protocol(Session, self._get_mapped_class(), 'geom')
        request = testing.DummyRequest()

        feature = proto.read(request, id='a')
        self.assertEqual(feature.id, 'a')
        self.assertEqual(feature.properties['text'], 'foo')
开发者ID:gberaudo,项目名称:papyrus,代码行数:19,代码来源:test_protocol.py

示例3: test_read_many

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

        engine = self._get_engine()
        Session = self._get_session(engine)
        MappedClass = self._get_mapped_class()

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

        def _query(request, filter):
            f1 = Feature(geometry=Point(1, 2))
            f2 = Feature(geometry=Point(2, 3))
            return [MappedClass(f1), MappedClass(f2)]
        proto._query = _query

        features = proto.read(testing.DummyRequest())
        self.assertTrue(isinstance(features, FeatureCollection))
        self.assertEqual(len(features.features), 2)
开发者ID:gberaudo,项目名称:papyrus,代码行数:22,代码来源:test_protocol.py


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