summaryrefslogtreecommitdiff
path: root/searx/tests/test_search.py
blob: 89d0b620db25f9f242caaae3a0cdb6c2dab8e155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-

from searx.search import score_results
from searx.testing import SearxTestCase


def fake_result(url='https://aa.bb/cc?dd=ee#ff',
                title='aaa',
                content='bbb',
                engine='wikipedia'):
    return {'url': url,
            'title': title,
            'content': content,
            'engine': engine}


class ScoreResultsTestCase(SearxTestCase):

    def test_empty(self):
        self.assertEqual(score_results(dict()), [])

    def test_urlparse(self):
        results = score_results(dict(a=[fake_result(url='https://aa.bb/cc?dd=ee#ff')]))
        parsed_url = results[0]['parsed_url']
        self.assertEqual(parsed_url.query, 'dd=ee')