示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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)