from collections import defaultdict import mock from searx.engines import archlinux from searx.testing import SearxTestCase domains = { 'all': 'https://wiki.archlinux.org', 'de': 'https://wiki.archlinux.de', 'fr': 'https://wiki.archlinux.fr', 'ja': 'https://wiki.archlinuxjp.org', 'ro': 'http://wiki.archlinux.ro', 'tr': 'http://archtr.org/wiki' } class TestArchLinuxEngine(SearxTestCase): def test_request(self): query = 'test_query' dic = defaultdict(dict) dic['pageno'] = 1 dic['language'] = 'en-US' params = archlinux.request(query, dic) self.assertTrue('url' in params) self.assertTrue(query in params['url']) self.assertTrue('wiki.archlinux.org' in params['url']) for lang, name in archlinux.main_langs: dic['language'] = lang params = archlinux.request(query, dic) self.assertTrue(name in params['url']) for lang, domain in domains.items(): dic['language'] = lang params = archlinux.request(query, dic) self.assertTrue(domain in params['url']) def test_response(self): response = mock.Mock(text='', search_params={'language': 'en_US'}) self.assertEqual(archlinux.response(response), []) html = """