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


Python processor.Processor类代码示例

本文整理汇总了Python中seishub.core.processor.Processor的典型用法代码示例。如果您正苦于以下问题:Python Processor类的具体用法?Python Processor怎么用?Python Processor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_deleteVersionControlledResource

 def test_deleteVersionControlledResource(self):
     """
     Successful deletion of version controlled resources.
     """
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/delete-test/vc/test.xml', StringIO(XML_DOC))
     proc.run(PUT, '/delete-test/vc/test.xml', StringIO(XML_VCDOC % 1))
     proc.run(PUT, '/delete-test/vc/test.xml', StringIO(XML_VCDOC % 2))
     # check latest resource - should be #20
     data = proc.run(GET, '/delete-test/vc/test.xml').render_GET(proc)
     self.assertEqual(data, XML_VCDOC % 2)
     # check oldest resource -> revision start with 1
     data = proc.run(GET, '/delete-test/vc/test.xml/1').render_GET(proc)
     self.assertEqual(data, XML_DOC)
     # delete resource
     data = proc.run(DELETE, '/delete-test/vc/test.xml')
     self.assertEqual(data, '')
     self.assertEqual(proc.code, http.NO_CONTENT)
     # fetch resource again
     try:
         proc.run(GET, '/delete-test/vc/test.xml').render_GET(proc)
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2: test_getRoot

 def test_getRoot(self):
     proc = Processor(self.env)
     data = proc.run(GET, "/")
     # data must be a dict
     self.assertTrue(isinstance(data, dict))
     # check content
     self.assertTrue("xml" in data.keys())
开发者ID:krischer,项目名称:seishub.core,代码行数:7,代码来源:test_tree.py

示例3: test_strangeRequestPatterns

 def test_strangeRequestPatterns(self):
     """
     Test strange request patterns.
     """
     proc = Processor(self.env)
     # root
     data = proc.run(GET, '///')
     self.assertTrue('xml' in data)
     data = proc.run(GET, '//./')
     self.assertTrue('xml' in data)
     # results in /xml
     data = proc.run(GET, '/xml//')
     self.assertTrue('seishub' in data)
     data = proc.run(GET, '//xml/')
     self.assertTrue('seishub' in data)
     data = proc.run(GET, '//////////////////////xml//////////////')
     self.assertTrue('seishub' in data)
     data = proc.run(GET, '/////////./////////////xml///////.////.///')
     self.assertTrue('seishub' in data)
     # results in /xml/seishub
     data = proc.run(GET, '//////////////////////xml/////////////seishub/')
     self.assertTrue('schema' in data)
     data = proc.run(GET, '/////////////////xml///////.//////seishub////')
     self.assertTrue('schema' in data)
     data = proc.run(GET, '/////////////////xml/../xml////seishub////')
     self.assertTrue('schema' in data)
开发者ID:,项目名称:,代码行数:26,代码来源:

示例4: test_processResource

 def test_processResource(self):
     proc = Processor(self.env)
     # upload a resource via POST
     data = proc.run(POST, '/xml/processor-test/notvc', StringIO(XML_DOC))
     # check response; data should be empty; we look into request
     self.assertFalse(data)
     self.assertEqual(proc.code, http.CREATED)
     self.assertTrue(isinstance(proc.headers, dict))
     self.assertTrue('Location' in proc.headers)
     location = proc.headers.get('Location')
     self.assertTrue(location.startswith(self.env.getRestUrl() + proc.path))
     # GET resource
     location = location[len(self.env.getRestUrl()):]
     data = proc.run(GET, location).render_GET(proc)
     self.assertEquals(data, XML_DOC)
     # overwrite this resource via PUT request
     proc.run(PUT, location, StringIO(XML_DOC2))
     # GET resource
     data = proc.run(GET, location).render_GET(proc)
     self.assertNotEquals(data, XML_DOC)
     self.assertEquals(data, XML_DOC2)
     # DELETE resource
     proc.run(DELETE, location)
     # GET deleted revision
     try:
         proc.run(GET, location).render_GET(proc)
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
开发者ID:,项目名称:,代码行数:29,代码来源:

示例5: __init__

 def __init__(self, channel, queued):
     self.env = channel.factory.env
     Processor.__init__(self, self.env)
     http.Request.__init__(self, channel, queued)
     self.notifications = []
     # fetch default pages configuration
     self.default_pages = \
         self.env.config.getlist('web', 'default_pages') or DEFAULT_PAGES
开发者ID:barsch,项目名称:seishub.core,代码行数:8,代码来源:web.py

示例6: test_invalidMethods

 def test_invalidMethods(self):
     proc = Processor(self.env)
     for method in ["MUH", "XXX", "GETPUT"]:
         try:
             proc.run(method, "/")
             self.fail("Expected SeisHubError")
         except SeisHubError, e:
             self.assertEqual(e.code, http.NOT_ALLOWED)
开发者ID:krischer,项目名称:seishub.core,代码行数:8,代码来源:test_tree.py

示例7: test_someRESTResourceTypes

 def test_someRESTResourceTypes(self):
     proc = Processor(self.env)
     result = proc.run(GET, "/")
     self.assertTrue(isinstance(result.get("xml"), RESTFolder))
     result = proc.run(GET, "/xml")
     self.assertTrue(isinstance(result.get("seishub"), RESTPackageFolder))
     result = proc.run(GET, "/xml/seishub")
     self.assertTrue(isinstance(result.get("stylesheet"), RESTResourceTypeFolder))
开发者ID:krischer,项目名称:seishub.core,代码行数:8,代码来源:test_tree.py

示例8: test_executeResourceScript

 def test_executeResourceScript(self):
     """
     Files with extension '.rpy' should be interpreted as Resource scripts.
     """
     proc = Processor(self.env)
     for method in [POST, PUT, DELETE, MOVE, GET]:
         data = proc.run(method, '/scripts/test.rpy')
         self.assertEquals('<html>%s</html>' % method, data)
开发者ID:barsch,项目名称:seishub.core,代码行数:8,代码来源:test_filesystem.py

示例9: test_getDisabledResourceType

 def test_getDisabledResourceType(self):
     proc = Processor(self.env)
     # without trailing slash
     try:
         proc.run(DELETE, '/get-test/notvc2')
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
开发者ID:,项目名称:,代码行数:8,代码来源:

示例10: test_dontReturnUnicodeFromMapper

 def test_dontReturnUnicodeFromMapper(self):
     """
     Unicodes returned from a mapper should be encoded into UTF-8 strings.
     """
     proc = Processor(self.env)
     data = proc.run(GET, '/testmapping4')
     self.assertFalse(isinstance(data, unicode))
     self.assertTrue(isinstance(data, basestring))
     self.assertEqual('MÜH', data)
开发者ID:barsch,项目名称:seishub.core,代码行数:9,代码来源:test_mapper.py

示例11: test_notImplementedMethods

 def test_notImplementedMethods(self):
     """
     Not implemented methods should raise an error.
     """
     proc = Processor(self.env)
     try:
         proc.run('MUH', '/testmapping4')
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_ALLOWED)
开发者ID:barsch,项目名称:seishub.core,代码行数:10,代码来源:test_mapper.py

示例12: test_deleteResourceInNotExistingResourceType

 def test_deleteResourceInNotExistingResourceType(self):
     """
     Resource can't be deleted from not existing resource type.
     """
     proc = Processor(self.env)
     try:
         proc.run(DELETE, '/delete-test/notvc2/test.xml')
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
开发者ID:,项目名称:,代码行数:10,代码来源:

示例13: process_POST

 def process_POST(self, request):
     """
     Just remap to the xml rest interface.
     """
     # Otherwise, just pass to the event xml resource handler.
     proc = Processor(self.env)
     path = "/xml/event_based_data/event"
     if request.postpath:
         path += "/" + "/".join(request.postpath)
     return proc.run(POST, path, StringIO(request.data))
开发者ID:krischer,项目名称:seishub.plugins.event_based_data,代码行数:10,代码来源:event_mappers.py

示例14: test_getResourceIndex

 def test_getResourceIndex(self):
     """
     Tests resource index property.
     """
     proc = Processor(self.env)
     XML_DOC = XML_BASE_DOC % ("üöäß", "5")
     # create resource
     proc.run(POST, '/property-test/notvc/test.xml', StringIO(XML_DOC))
     # get index XML w/o trailing slash
     res = proc.run(GET, '/property-test/notvc/test.xml/.index')
     data = res.render_GET(proc)
     self.assertTrue("<label1>" in data)
     self.assertTrue("<value>üöäß</value>" in data)
     # get index XML w/ trailing slash
     res = proc.run(GET, '/property-test/notvc/test.xml/.index/')
     data = res.render_GET(proc)
     self.assertTrue("<label1>" in data)
     self.assertTrue("<value>üöäß</value>" in data)
     # get index XML on revision 1 w/o trailing slash
     res = proc.run(GET, '/property-test/notvc/test.xml/1/.index/')
     data = res.render_GET(proc)
     self.assertTrue("<label1>" in data)
     self.assertTrue("<value>üöäß</value>" in data)
     # get index XML on revision 1 w/ trailing slash
     res = proc.run(GET, '/property-test/notvc/test.xml/1/.index/')
     data = res.render_GET(proc)
     self.assertTrue("<label1>" in data)
     self.assertTrue("<value>üöäß</value>" in data)
     # remove resource
     proc.run(DELETE, '/property-test/notvc/test.xml')
开发者ID:krischer,项目名称:seishub.core,代码行数:30,代码来源:test_rest_property.py

示例15: test_getRevisionFromNotVersionControlledResource

 def test_getRevisionFromNotVersionControlledResource(self):
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/get-test/notvc/test.xml', StringIO(XML_DOC))
     proc.run(PUT, '/get-test/notvc/test.xml', StringIO(XML_DOC))
     proc.run(PUT, '/get-test/notvc/test.xml', StringIO(XML_DOC))
     # revision #1 always exist
     # without trailing slash
     res1 = proc.run(GET, '/get-test/notvc/test.xml/1')
     data1 = res1.render(proc)
     # with trailing slash
     res2 = proc.run(GET, '/get-test/notvc/test.xml/1/')
     data2 = res2.render(proc)
     # res must be RESTResource objects
     self.assertTrue(isinstance(res1, RESTResource))
     self.assertTrue(isinstance(res2, RESTResource))
     # both results should equal
     self.assertTrue(Set(data1) == Set(data2))
     # data must be a basestring
     self.assertTrue(isinstance(data1, basestring))
     # check content
     self.assertEquals(data1, XML_DOC)
     # try to GET revision 2
     try:
         proc.run(GET, '/get-test/notvc/test.xml/2')
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
开发者ID:,项目名称:,代码行数:27,代码来源:


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