Exemple #1
0
    def test_no_highlights(self):
        """
        Test when there are no highlights
        """
        sq = SearchQuery(q='star', fl=['bibcode'], hl=['abstract'])
        with MockSolrResponse(SEARCH_URL):
            p = list(sq)[1]

        highlights = sq.highlights(p)
        self.assertEqual(highlights, {})
Exemple #2
0
    def test_no_highlights(self):
        """
        Test when there are no highlights
        """
        sq = SearchQuery(q='star', fl=['bibcode'], hl=['abstract'])
        with MockSolrResponse(SEARCH_URL):
            p = list(sq)[1]

        highlights = sq.highlights(p)
        self.assertEqual(highlights, {})
Exemple #3
0
    def test_get_highlight(self):
        """
        Test can retrieve a highlight for a given bibcode for a given query
        """
        sq = SearchQuery(q='star')
        self.assertNotIn('hl', sq.query)
        self.assertNotIn('hl.fl', sq.query)

        sq = SearchQuery(q='star', fl=['bibcode'], hl=['abstract'])
        self.assertEqual(sq.query['hl'], 'true')
        self.assertEqual(sq.query['hl.fl'], ['abstract'])
        with MockSolrResponse(SEARCH_URL):
            p = list(sq)[0]

        highlights = sq.highlights(p)
        self.assertEqual(highlights, {'abstract': 'astronomy abstract'})
Exemple #4
0
    def test_get_highlight(self):
        """
        Test can retrieve a highlight for a given bibcode for a given query
        """
        sq = SearchQuery(q='star')
        self.assertNotIn('hl', sq.query)
        self.assertNotIn('hl.fl', sq.query)

        sq = SearchQuery(q='star', fl=['bibcode'], hl=['abstract'])
        self.assertEqual(sq.query['hl'], 'true')
        self.assertEqual(sq.query['hl.fl'], ['abstract'])
        with MockSolrResponse(SEARCH_URL):
            p = list(sq)[0]

        highlights = sq.highlights(p)
        self.assertEqual(highlights, {'abstract': 'astronomy abstract'})