當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。