def testSpecialCharacters(self): suggestions = Suggestion(count=1, field='afield') response = Response(total=0, hits=[]) response.suggestions={'Éäéðĉ': ['Éäéðĉ']} responseData = ''.join(compose(suggestions.extraResponseData(response=response, sruArguments={'x-suggestionsQuery':['Éäéðĉ']}))) self.assertXmlEquals("""<suggestions xmlns="http://meresco.org/namespace/suggestions"> <suggestion>Éäéðĉ</suggestion> </suggestions> """, responseData)
def testHarriePoter(self): suggestions = Suggestion(count=1, field='afield') response = Response(total=0, hits=[]) response.suggestions={'harrie': ['harry', 'marie'], 'poter': ['potter', 'peter'] } responseData = ''.join(compose(suggestions.extraResponseData(response=response, sruArguments={'x-suggestionsQuery':["harrie AND poter"]}))) self.assertEqualsWS("""<suggestions xmlns="http://meresco.org/namespace/suggestions"> <suggestion>harry AND potter</suggestion> <suggestion>marie AND peter</suggestion> </suggestions> """, responseData)
def testCreateExtraResponseDataWithMultipleSuggestions(self): suggestions = Suggestion(count=1, field='afield') response = Response(total=0, hits=[]) response.suggestions={'query': ['que', 'emery', 'queen'], 'value': ['valu', 'ot'] } responseData = ''.join(compose(suggestions.extraResponseData(response=response, sruArguments={'x-suggestionsQuery':["query AND value"]}))) self.assertEqualsWS("""<suggestions xmlns="http://meresco.org/namespace/suggestions"> <suggestion>que AND valu</suggestion> <suggestion>emery AND ot</suggestion> </suggestions> """, responseData)
def testSpecialCharacters(self): suggestions = Suggestion(count=1, field='afield') response = Response(total=0, hits=[]) response.suggestions = {'Éäéðĉ': ['Éäéðĉ']} responseData = ''.join( compose( suggestions.extraResponseData( response=response, sruArguments={'x-suggestionsQuery': ['Éäéðĉ']}))) self.assertXmlEquals( """<suggestions xmlns="http://meresco.org/namespace/suggestions"> <suggestion>Éäéðĉ</suggestion> </suggestions> """, responseData)
def testCreateExtraResponseDataWithMultipleSuggestions(self): suggestions = Suggestion(count=1, field='afield') response = Response(total=0, hits=[]) response.suggestions = { 'query': ['que', 'emery', 'queen'], 'value': ['valu', 'ot'] } responseData = ''.join( compose( suggestions.extraResponseData( response=response, sruArguments={'x-suggestionsQuery': ["query AND value"]}))) self.assertEqualsWS( """<suggestions xmlns="http://meresco.org/namespace/suggestions"> <suggestion>que AND valu</suggestion> <suggestion>emery AND ot</suggestion> </suggestions> """, responseData)
def testHarriePoter(self): suggestions = Suggestion(count=1, field='afield') response = Response(total=0, hits=[]) response.suggestions = { 'harrie': ['harry', 'marie'], 'poter': ['potter', 'peter'] } responseData = ''.join( compose( suggestions.extraResponseData( response=response, sruArguments={'x-suggestionsQuery': ["harrie AND poter"]}))) self.assertEqualsWS( """<suggestions xmlns="http://meresco.org/namespace/suggestions"> <suggestion>harry AND potter</suggestion> <suggestion>marie AND peter</suggestion> </suggestions> """, responseData)