MCPcopy Create free account
hub / github.com/django-haystack/django-haystack / search

Method search

test_haystack/mocks.py:140–159  ·  view source on GitHub ↗
(self, query_string, **kwargs)

Source from the content-addressed store, hash-verified

138class MixedMockSearchBackend(MockSearchBackend):
139 @log_query
140 def search(self, query_string, **kwargs):
141 if kwargs.get("end_offset") and kwargs["end_offset"] > 30:
142 kwargs["end_offset"] = 30
143
144 result_info = super().search(query_string, **kwargs)
145 result_info["hits"] = 30
146
147 # Remove search results from other models.
148 temp_results = []
149
150 for result in result_info["results"]:
151 if not int(result.pk) in (9, 13, 14):
152 # MockSearchResult('core', 'AnotherMockModel', 9, .1)
153 # MockSearchResult('core', 'AnotherMockModel', 13, .1)
154 # MockSearchResult('core', 'NonexistentMockModel', 14, .1)
155 temp_results.append(result)
156
157 result_info["results"] = temp_results
158
159 return result_info
160
161
162class MockSearchQuery(BaseSearchQuery):

Callers

nothing calls this directly

Calls 2

getMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected