本文整理汇总了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)
示例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)
示例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)
示例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'])
示例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)