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


Python MockServ.reset方法代码示例

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


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

示例1: test_reset_unordered

# 需要导入模块: from mapproxy.test.http import MockServ [as 别名]
# 或者: from mapproxy.test.http.MockServ import reset [as 别名]
    def test_reset_unordered(self):
        serv = MockServ(unordered=True)
        serv.expects('/test1').returns(body=b'hello1')
        serv.expects('/test2').returns(body=b'hello2')

        with serv:
            resp = requests.get('http://localhost:%d/test1' % serv.port)
            eq_(resp.content, b'hello1')
            resp = requests.get('http://localhost:%d/test2' % serv.port)
            eq_(resp.content, b'hello2')

        serv.reset()
        with serv:
            resp = requests.get('http://localhost:%d/test2' % serv.port)
            eq_(resp.content, b'hello2')
            resp = requests.get('http://localhost:%d/test1' % serv.port)
            eq_(resp.content, b'hello1')
开发者ID:LKajan,项目名称:mapproxy,代码行数:19,代码来源:test_http_helper.py

示例2: test_add_get_edit_delete

# 需要导入模块: from mapproxy.test.http import MockServ [as 别名]
# 或者: from mapproxy.test.http.MockServ import reset [as 别名]
    def test_add_get_edit_delete(self):
        mock_serv = MockServ()
        mock_serv.expects('/foo/service?REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1')
        cap_file = os.path.join(os.path.dirname(__file__), 'fixtures', 'wms_nasa_cap.xml')
        mock_serv.returns(body_file=cap_file)
        with mock_serv:
            resp = self.app.post_json('/conf/base/wms_capabilities', {'data': {'url': mock_serv.base_url + '/foo/service'}})

        id = resp.json['_id']

        expected = {
            '_id': id,
            'data': {
                'abstract': helper.ANY,
                'title': 'JPL Global Imagery Service',
                'url': 'http://wms.jpl.nasa.gov/wms.cgi?',
                'layer': helper.ANY,
            }
        }
        assert resp.json == expected

        resp = self.app.get('/conf/base/wms_capabilities/%d' % resp.json['_id'])
        expected.pop('_id') # remove if we decide to pass _id in get request
        assert resp.json == expected

        resp = self.app.get('/conf/base/wms_capabilities')
        # add vars returned by function
        expected['_id'] = id
        expected['_locked'] = 0
        expected['_manual'] = 0
        expected['_section'] = 'wms_capabilities'
        assert resp.json == {str(id): expected}
        mock_serv.reset()

        with mock_serv:
            resp = self.app.put_json('/conf/base/wms_capabilities/%d' % id, {'data': {'url': mock_serv.base_url + '/foo/service'}})

        resp = self.app.delete('/conf/base/wms_capabilities/%d' % id)
        assert resp.status_code == 204
        resp = self.app.get('/conf/base/wms_capabilities/%d' % id, status=404)
开发者ID:tudorbarascu,项目名称:mapproxy-webconf,代码行数:42,代码来源:test_api.py


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