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


Python DummyRequest.matchdict['path']方法代码示例

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


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

示例1: test_ondemend_wmtscapabilities

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import matchdict['path'] [as 别名]
 def test_ondemend_wmtscapabilities(self, l):
     server.pyramid_server = None
     server.tilegeneration = None
     request = DummyRequest()
     request.registry.settings = {
         'tilegeneration_configfile': 'tilegeneration/test-serve-wmtscapabilities.yaml',
     }
     request.matchdict['path'] = [
         'wmts', '1.0.0', 'WMTSCapabilities.xml'
     ]
     PyramidView(request)()
     self.assertEqual(request.response.headers['Content-Type'], 'application/xml')
     self.assert_result_equals(
         request.response.body.decode('utf-8') if PY3 else request.response.body,
         CAPABILITIES,
         regex=True,
     )
     l.check()
开发者ID:camptocamp,项目名称:tilecloud-chain,代码行数:20,代码来源:test_serve.py

示例2: test_bsddb_rest

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import matchdict['path'] [as 别名]
    def test_bsddb_rest(self, l):
        self.assert_tiles_generated(
            cmd='.build/venv/bin/generate_tiles -d -c tilegeneration/test-bsddb.yaml'
                ' -l point_hash --zoom 1',
            main_func=generate.main,
            directory="/tmp/tiles/bsddb/",
            tiles_pattern='1.0.0/%s',
            tiles=[
                ('point_hash/default/2012/swissgrid_5.png.bsddb')
            ],
            regex=True,
            expected="""The tile generation of layer 'point_hash \(DATE=2012\)' is finish
Nb generated metatiles: 1
Nb metatiles dropped: 0
Nb generated tiles: 64
Nb tiles dropped: 62
Nb tiles stored: 2
Nb tiles in error: 0
Total time: [0-9]+:[0-9][0-9]:[0-9][0-9]
Total size: [89][0-9][0-9] o
Time per tile: [0-9]+ ms
Size per tile: 4[0-9][0-9] o

""",
        )
        # use delete to don't delete the repository
        self.assert_tiles_generated_deleted(
            cmd='.build/venv/bin/generate_controller --capabilities -c tilegeneration/test-bsddb.yaml',
            main_func=controller.main,
            directory="/tmp/tiles/bsddb/",
            tiles_pattern='1.0.0/%s',
            tiles=[
                ('WMTSCapabilities.xml'),
                ('point_hash/default/2012/swissgrid_5.png.bsddb')
            ],
        )

        request = DummyRequest()
        request.registry.settings = {
            'tilegeneration_configfile': 'tilegeneration/test-bsddb.yaml',
        }
        request.matchdict = {
            'path': [
                'wmts', '1.0.0', 'point_hash', 'default', '2012', 'swissgrid_5', '1', '11', '14.png'
            ]
        }
        serve = PyramidView(request)
        serve()
        self.assertEqual(request.response.headers['Content-Type'], 'image/png')
        self.assertEqual(request.response.headers['Cache-Control'], 'max-age=28800')

        request.matchdict['path'][7] = '12'
        self.assertRaises(HTTPNoContent, serve)

        request.matchdict['path'][7] = '11'
        request.matchdict['path'][1] = '0.9'
        self.assertRaises(HTTPBadRequest, serve)

        request.matchdict['path'][1] = '1.0.0'
        request.matchdict['path'][8] = '14.jpeg'
        self.assertRaises(HTTPBadRequest, serve)

        request.matchdict['path'][8] = '14.png'
        request.matchdict['path'][2] = 'test'
        self.assertRaises(HTTPBadRequest, serve)

        request.matchdict['path'][2] = 'point_hash'
        request.matchdict['path'][3] = 'test'
        self.assertRaises(HTTPBadRequest, serve)

        request.matchdict['path'][3] = 'default'
        request.matchdict['path'][5] = 'test'
        self.assertRaises(HTTPBadRequest, serve)

        request.matchdict['path'] = [
            'wmts', 'point_hash', 'default', 'swissgrid_5', '1', '14', '11.png'
        ]
        self.assertRaises(HTTPBadRequest, serve)

        request.matchdict['path'] = [
            'wmts', '1.0.0', 'WMTSCapabilities.xml'
        ]
        PyramidView(request)()
        self.assertEqual(request.response.headers['Content-Type'], 'application/xml')
        self.assert_result_equals(
            request.response.body.decode('utf-8') if PY3 else request.response.body,
            CAPABILITIES,
            regex=True,
        )

        request.matchdict['path'] = [
            'static', '1.0.0', 'WMTSCapabilities.xml'
        ]
        PyramidView(request)()
        self.assertEqual(request.response.headers['Content-Type'], 'application/xml')
        self.assert_result_equals(
            request.response.body.decode('utf-8') if PY3 else request.response.body,
            CAPABILITIES,
            regex=True,
        )
#.........这里部分代码省略.........
开发者ID:ochriste,项目名称:tilecloud-chain,代码行数:103,代码来源:test_serve.py


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