def test_no_suggest(self): portal = self.layer['portal'] request = self.layer['request'] # Setup browser layers notify(BeforeTraverseEvent(portal, request)) # Setup solr suggest response response = getData('nosuggest_response.txt') proc = queryUtility(ISolrConnectionManager) proc.setHost(active=True) conn = proc.getConnection() fakehttp(conn, response) request.form.update({'term': 'abx'}) view = getMultiAdapter((portal, request), name=u'suggest-terms') suggestions = json.loads(view()) self.assertEquals(len(suggestions), 0)
def test_facets_order(self): portal = self.layer['portal'] request = self.layer['request'] request.form.update({'facet_field': ['type', 'section', 'topics']}) response = SolrResponse(getData('facets_response.xml')) view = SearchFacetsView(portal, request) view.kw = dict(results=response) config = queryUtility(ISolrConnectionConfig) config.facets = ['type', 'section', 'topics'] facets = view.facets() self.assertEquals(['type', 'section', 'topics'], [facets[0]['title'], facets[1]['title'], facets[2]['title']], msg='Wrong facet order.') config.facets = ['section', 'topics', 'type'] facets = view.facets() self.assertEquals(['section', 'topics', 'type'], [facets[0]['title'], facets[1]['title'], facets[2]['title']], msg='Wrong facet order.')