on master help sign in
[fix] engine test
e74bdf8Adam Tauber
tests/unit/engines/test_startpage.py+25−98
@@ -18,12 +18,9 @@ class TestStartpageEngine(SearxTestCase):
18 self.assertIn('data', params)
18 self.assertIn('data', params)
19 self.assertIn('query', params['data'])
19 self.assertIn('query', params['data'])
20 self.assertIn(query, params['data']['query'])
20 self.assertIn(query, params['data']['query'])
21− self.assertIn('with_language', params['data'])
22− self.assertIn('lang_fr', params['data']['with_language'])
23
21
24 dicto['language'] = 'all'
22 dicto['language'] = 'all'
25 params = startpage.request(query, dicto)
23 params = startpage.request(query, dicto)
26− self.assertNotIn('with_language', params['data'])
27
24
28 def test_response(self):
25 def test_response(self):
29 self.assertRaises(AttributeError, startpage.response, None)
26 self.assertRaises(AttributeError, startpage.response, None)
@@ -35,33 +32,32 @@ class TestStartpageEngine(SearxTestCase):
35 self.assertEqual(startpage.response(response), [])
32 self.assertEqual(startpage.response(response), [])
36
33
37 html = """
34 html = """
38− <li class="search-result search-item">
35+<div class="w-gl__result">
39− <h3>
36+ <a
37+ class="w-gl__result-title"
40− <a href='http://this.should.be.the.link/' id='title_2' name='title_2' >
38+ href="http://this.should.be.the.link/"
39+ data-onw="1"
40+ rel="noopener noreferrer"
41+ target="_blank">
42+
41− This should be the title
43+ <h3>This should be the title</h3>
42 </a>
44 </a>
43− <span id='title_stars_2' name='title_stars_2'> </span>
45+ <div class="w-gl__result-second-line-container">
44− </h3>
46+ <div class="w-gl__result-url-container">
45− <p class="search-item__body">
47+ <a
48+ class="w-gl__result-url"
46− This should be the content.
49+ href="http://this.should.be.the.link/"
47− </p>
50+ rel="noopener noreferrer"
48− <p>
51+ target="_blank">https://www.cnbc.com/2019/10/12/dj-zedd-banned-in-china-for-liking-a-south-park-tweet.html</a>
49− <span class='url'>www.speed<b>test</b>.net/fr/
52+ </div>
50− </span>
53+ <a
51− -
54+ class="w-gl__anonymous-view-url"
52− <A class="proxy" id="proxy_link" HREF="https://ixquick-proxy.com/do/spg/proxy?ep=&edata=&ek=&ekdata="
55+ href="https://eu-browse.startpage.com/do/proxy?ep=556b554d576b6f5054554546423167764b5445616455554d5342675441774659495246304848774f5267385453304941486b5949546c63704e33774f526b705544565647516d4a61554246304847674f4a556f6957415a4f436b455042426b6b4f7a64535a52784a56514a4f45307743446c567250445a4f4c52514e5677554e46776b4b545563704c7931554c5167465467644f42464d4f4255426f4d693152624634525741305845526c595746636b626d67494e42705743466c515252634f4267456e597a7346596b7856435134465345634f564249794b5752785643315863546769515773764a5163494c5877505246315865456f5141426b4f41774167596d6c5a4e30395758773442465251495677596c624770665a6b786344466b4151455663425249794d6a78525a55554157516f4342556766526b51314b57514e&amp;ek=4q58686o5047786n6343527259445247576p6o38&amp;ekdata=84abd523dc13cba5c65164d04d7d7263"
53− class='proxy'>
56+ target="_blank">Anonymous View</a>
54− Navigation avec Ixquick Proxy
57+ </div>
55− </A>
58+ <p class="w-gl__description">This should be the content.</p>
56− -
59+ </div>
57− <A HREF="https://ixquick-proxy.com/do/spg/highlight.pl?l=francais&c=hf&cat=web&q=test&rl=NONE&rid=
58− &hlq=https://startpage.com/do/search&mtabp=-1&mtcmd=process_search&mtlanguage=francais&mtengine0=
59− &mtcat=web&u=http:%2F%2Fwww.speedtest.net%2Ffr%2F" class='proxy'>
60− Mis en surbrillance
61− </A>
62− </p>
63− </li>
64− """
60+ """ # noqa
65 response = mock.Mock(text=html.encode('utf-8'))
61 response = mock.Mock(text=html.encode('utf-8'))
66 results = startpage.response(response)
62 results = startpage.response(response)
67 self.assertEqual(type(results), list)
63 self.assertEqual(type(results), list)
@@ -69,72 +65,3 @@ class TestStartpageEngine(SearxTestCase):
69 self.assertEqual(results[0]['title'], 'This should be the title')
65 self.assertEqual(results[0]['title'], 'This should be the title')
70 self.assertEqual(results[0]['url'], 'http://this.should.be.the.link/')
66 self.assertEqual(results[0]['url'], 'http://this.should.be.the.link/')
71 self.assertEqual(results[0]['content'], 'This should be the content.')
67 self.assertEqual(results[0]['content'], 'This should be the content.')
72−
73− html = """
74− <li class="search-result search-item">
75− <h3>
76− <a href='http://www.google.com/aclk?sa=l&ai=C' id='title_2' name='title_2' >
77− This should be the title
78− </a>
79− <span id='title_stars_2' name='title_stars_2'> </span>
80− </h3>
81− <p class="search-item__body">
82− This should be the content.
83− </p>
84− <p>
85− <span class='url'>www.speed<b>test</b>.net/fr/
86− </span>
87− -
88− <A class="proxy" id="proxy_link" HREF="https://ixquick-proxy.com/do/spg/proxy?ep=&edata=&ek=&ekdata="
89− class='proxy'>
90− Navigation avec Ixquick Proxy
91− </A>
92− -
93− <A HREF="https://ixquick-proxy.com/do/spg/highlight.pl?l=francais&c=hf&cat=web&q=test&rl=NONE&rid=
94− &hlq=https://startpage.com/do/search&mtabp=-1&mtcmd=process_search&mtlanguage=francais&mtengine0=
95− &mtcat=web&u=http:%2F%2Fwww.speedtest.net%2Ffr%2F" class='proxy'>
96− Mis en surbrillance
97− </A>
98− </p>
99− </li>
100− <li class="search-result search-item">
101− <h3>
102− <span id='title_stars_2' name='title_stars_2'> </span>
103− </h3>
104− <p class="search-item__body">
105− This should be the content.
106− </p>
107− <p>
108− <span class='url'>www.speed<b>test</b>.net/fr/
109− </span>
110− </p>
111− </li>
112− <li class="search-result search-item">
113− <h3>
114− <a href='http://this.should.be.the.link/' id='title_2' name='title_2' >
115− This should be the title
116− </a>
117− <span id='title_stars_2' name='title_stars_2'> </span>
118− </h3>
119− <p>
120− <span class='url'>www.speed<b>test</b>.net/fr/
121− </span>
122− -
123− <A class="proxy" id="proxy_link" HREF="https://ixquick-proxy.com/do/spg/proxy?ep=&edata=&ek=&ekdata="
124− class='proxy'>
125− Navigation avec Ixquick Proxy
126− </A>
127− -
128− <A HREF="https://ixquick-proxy.com/do/spg/highlight.pl?l=francais&c=hf&cat=web&q=test&rl=NONE&rid=
129− &hlq=https://startpage.com/do/search&mtabp=-1&mtcmd=process_search&mtlanguage=francais&mtengine0=
130− &mtcat=web&u=http:%2F%2Fwww.speedtest.net%2Ffr%2F" class='proxy'>
131− Mis en surbrillance
132− </A>
133− </p>
134− </li>
135− """
136− response = mock.Mock(text=html.encode('utf-8'))
137− results = startpage.response(response)
138− self.assertEqual(type(results), list)
139− self.assertEqual(len(results), 1)
140− self.assertEqual(results[0]['content'], '')