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


Python SruHandler._writeExtraResponseData方法代码示例

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


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

示例1: testExtraResponseDataHandlerNoData

# 需要导入模块: from meresco.components.sru import SruHandler [as 别名]
# 或者: from meresco.components.sru.SruHandler import _writeExtraResponseData [as 别名]
    def testExtraResponseDataHandlerNoData(self):
        class TestHandler:
            def extraResponseData(self, *args, **kwargs):
                return (f for f in [])

        component = SruHandler()
        component.addObserver(TestHandler())
        result = "".join(list(component._writeExtraResponseData(cqlAbstractSyntaxTree=None, **MOCKDATA)))
        self.assertEquals('' , result)
开发者ID:seecr,项目名称:meresco-components,代码行数:11,代码来源:sruhandlertest.py

示例2: testExceptionInWriteExtraRecordData

# 需要导入模块: from meresco.components.sru import SruHandler [as 别名]
# 或者: from meresco.components.sru.SruHandler import _writeExtraResponseData [as 别名]
 def testExceptionInWriteExtraRecordData(self):
     class RaisesException(object):
         def extraResponseData(self, *args, **kwargs):
             raise Exception("Test Exception")
     component = SruHandler()
     component.addObserver(RaisesException())
     result = "".join(compose(component._writeExtraResponseData(cqlAbstractSyntaxTree=None, **MOCKDATA)))
     self.assertTrue("<uri>info://srw/diagnostics/1/1</uri>" in result)
     self.assertTrue("<message>General System Error</message>" in result)
     self.assertTrue("<details>Test Exception</details>" in result)
开发者ID:seecr,项目名称:meresco-components,代码行数:12,代码来源:sruhandlertest.py

示例3: testExtraResponseDataWithTermDrilldown

# 需要导入模块: from meresco.components.sru import SruHandler [as 别名]
# 或者: from meresco.components.sru.SruHandler import _writeExtraResponseData [as 别名]
 def testExtraResponseDataWithTermDrilldown(self):
     sruHandler = SruHandler()
     sruTermDrilldown = SRUTermDrilldown()
     drilldownData = [
             {'fieldname': 'field0', 'terms': [{'term': 'value0_0', 'count': 14}]},
             {'fieldname': 'field1', 'terms': [{'term': 'value1_0', 'count': 13}, {'term': 'value1_1', 'count': 11}]},
             {'fieldname': 'field2', 'terms': [{'term': 'value2_0', 'count': 3}, {'term': 'value2_1', 'count': 2}, {'term': 'value2_2', 'count': 1}]}
         ]
     sruHandler.addObserver(sruTermDrilldown)
     result = "".join(sruHandler._writeExtraResponseData(drilldownData=drilldownData, sruArguments={}, **MOCKDATA))
     self.assertEqualsWS("""<srw:extraResponseData><dd:drilldown\n    xmlns:dd="http://meresco.org/namespace/drilldown"\n    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n    xsi:schemaLocation="http://meresco.org/namespace/drilldown http://meresco.org/files/xsd/drilldown-20070730.xsd"><dd:term-drilldown><dd:navigator name="field0"><dd:item count="14">value0_0</dd:item></dd:navigator><dd:navigator name="field1"><dd:item count="13">value1_0</dd:item><dd:item count="11">value1_1</dd:item></dd:navigator><dd:navigator name="field2"><dd:item count="3">value2_0</dd:item><dd:item count="2">value2_1</dd:item><dd:item count="1">value2_2</dd:item></dd:navigator></dd:term-drilldown></dd:drilldown></srw:extraResponseData>""" , result)
开发者ID:seecr,项目名称:meresco-components,代码行数:13,代码来源:sruhandlertest.py

示例4: testExtraResponseDataHandlerWithData

# 需要导入模块: from meresco.components.sru import SruHandler [as 别名]
# 或者: from meresco.components.sru.SruHandler import _writeExtraResponseData [as 别名]
    def testExtraResponseDataHandlerWithData(self):
        argsUsed = []
        kwargsUsed = {}
        class TestHandler:
            def extraResponseData(self, *args, **kwargs):
                argsUsed.append(args)
                kwargsUsed.update(kwargs)
                return (f for f in ["<someD", "ata/>"])

        component = SruHandler()
        component.addObserver(TestHandler())
        result = "".join(list(component._writeExtraResponseData(cqlAbstractSyntaxTree=None, **MOCKDATA)))
        self.assertEquals('<srw:extraResponseData><someData/></srw:extraResponseData>' , result)
        self.assertEquals([()], argsUsed)
        self.assertEquals(None, kwargsUsed['cqlAbstractSyntaxTree'])
        self.assertEquals(MOCKDATA['queryTime'], kwargsUsed['queryTime'])
        self.assertEquals(MOCKDATA['response'], kwargsUsed['response'])
开发者ID:seecr,项目名称:meresco-components,代码行数:19,代码来源:sruhandlertest.py

示例5: testExtraResponseDataHandlerNoHandler

# 需要导入模块: from meresco.components.sru import SruHandler [as 别名]
# 或者: from meresco.components.sru.SruHandler import _writeExtraResponseData [as 别名]
 def testExtraResponseDataHandlerNoHandler(self):
     component = SruHandler()
     result = "".join(list(component._writeExtraResponseData(cqlAbstractSyntaxTree=None, **MOCKDATA)))
     self.assertEquals('' , result)
开发者ID:seecr,项目名称:meresco-components,代码行数:6,代码来源:sruhandlertest.py


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