Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
searx-engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
searx-engine
Commits
e74bdf84
Commit
e74bdf84
authored
Oct 14, 2019
by
Adam Tauber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] engine test
parent
27ed31c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
98 deletions
+25
-98
test_startpage.py
tests/unit/engines/test_startpage.py
+25
-98
No files found.
tests/unit/engines/test_startpage.py
View file @
e74bdf84
...
...
@@ -18,12 +18,9 @@ class TestStartpageEngine(SearxTestCase):
self
.
assertIn
(
'data'
,
params
)
self
.
assertIn
(
'query'
,
params
[
'data'
])
self
.
assertIn
(
query
,
params
[
'data'
][
'query'
])
self
.
assertIn
(
'with_language'
,
params
[
'data'
])
self
.
assertIn
(
'lang_fr'
,
params
[
'data'
][
'with_language'
])
dicto
[
'language'
]
=
'all'
params
=
startpage
.
request
(
query
,
dicto
)
self
.
assertNotIn
(
'with_language'
,
params
[
'data'
])
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
startpage
.
response
,
None
)
...
...
@@ -35,33 +32,32 @@ class TestStartpageEngine(SearxTestCase):
self
.
assertEqual
(
startpage
.
response
(
response
),
[])
html
=
"""
<li class="search-result search-item">
<h3>
<a href='http://this.should.be.the.link/' id='title_2' name='title_2' >
This should be the title
<div class="w-gl__result">
<a
class="w-gl__result-title"
href="http://this.should.be.the.link/"
data-onw="1"
rel="noopener noreferrer"
target="_blank">
<h3>This should be the title</h3>
</a>
<span id='title_stars_2' name='title_stars_2'> </span>
</h3>
<p class="search-item__body">
This should be the content.
</p>
<p>
<span class='url'>www.speed<b>test</b>.net/fr/
</span>
-
<A class="proxy" id="proxy_link" HREF="https://ixquick-proxy.com/do/spg/proxy?ep=&edata=&ek=&ekdata="
class='proxy'>
Navigation avec Ixquick Proxy
</A>
-
<A HREF="https://ixquick-proxy.com/do/spg/highlight.pl?l=francais&c=hf&cat=web&q=test&rl=NONE&rid=
&hlq=https://startpage.com/do/search&mtabp=-1&mtcmd=process_search&mtlanguage=francais&mtengine0=
&mtcat=web&u=http:
%2
F
%2
Fwww.speedtest.net
%2
Ffr
%2
F" class='proxy'>
Mis en surbrillance
</A>
</p>
</li>
"""
<div class="w-gl__result-second-line-container">
<div class="w-gl__result-url-container">
<a
class="w-gl__result-url"
href="http://this.should.be.the.link/"
rel="noopener noreferrer"
target="_blank">https://www.cnbc.com/2019/10/12/dj-zedd-banned-in-china-for-liking-a-south-park-tweet.html</a>
</div>
<a
class="w-gl__anonymous-view-url"
href="https://eu-browse.startpage.com/do/proxy?ep=556b554d576b6f5054554546423167764b5445616455554d5342675441774659495246304848774f5267385453304941486b5949546c63704e33774f526b705544565647516d4a61554246304847674f4a556f6957415a4f436b455042426b6b4f7a64535a52784a56514a4f45307743446c567250445a4f4c52514e5677554e46776b4b545563704c7931554c5167465467644f42464d4f4255426f4d693152624634525741305845526c595746636b626d67494e42705743466c515252634f4267456e597a7346596b7856435134465345634f564249794b5752785643315863546769515773764a5163494c5877505246315865456f5141426b4f41774167596d6c5a4e30395758773442465251495677596c624770665a6b786344466b4151455663425249794d6a78525a55554157516f4342556766526b51314b57514e&ek=4q58686o5047786n6343527259445247576p6o38&ekdata=84abd523dc13cba5c65164d04d7d7263"
target="_blank">Anonymous View</a>
</div>
<p class="w-gl__description">This should be the content.</p>
</div>
"""
# noqa
response
=
mock
.
Mock
(
text
=
html
.
encode
(
'utf-8'
))
results
=
startpage
.
response
(
response
)
self
.
assertEqual
(
type
(
results
),
list
)
...
...
@@ -69,72 +65,3 @@ class TestStartpageEngine(SearxTestCase):
self
.
assertEqual
(
results
[
0
][
'title'
],
'This should be the title'
)
self
.
assertEqual
(
results
[
0
][
'url'
],
'http://this.should.be.the.link/'
)
self
.
assertEqual
(
results
[
0
][
'content'
],
'This should be the content.'
)
html
=
"""
<li class="search-result search-item">
<h3>
<a href='http://www.google.com/aclk?sa=l&ai=C' id='title_2' name='title_2' >
This should be the title
</a>
<span id='title_stars_2' name='title_stars_2'> </span>
</h3>
<p class="search-item__body">
This should be the content.
</p>
<p>
<span class='url'>www.speed<b>test</b>.net/fr/
</span>
-
<A class="proxy" id="proxy_link" HREF="https://ixquick-proxy.com/do/spg/proxy?ep=&edata=&ek=&ekdata="
class='proxy'>
Navigation avec Ixquick Proxy
</A>
-
<A HREF="https://ixquick-proxy.com/do/spg/highlight.pl?l=francais&c=hf&cat=web&q=test&rl=NONE&rid=
&hlq=https://startpage.com/do/search&mtabp=-1&mtcmd=process_search&mtlanguage=francais&mtengine0=
&mtcat=web&u=http:
%2
F
%2
Fwww.speedtest.net
%2
Ffr
%2
F" class='proxy'>
Mis en surbrillance
</A>
</p>
</li>
<li class="search-result search-item">
<h3>
<span id='title_stars_2' name='title_stars_2'> </span>
</h3>
<p class="search-item__body">
This should be the content.
</p>
<p>
<span class='url'>www.speed<b>test</b>.net/fr/
</span>
</p>
</li>
<li class="search-result search-item">
<h3>
<a href='http://this.should.be.the.link/' id='title_2' name='title_2' >
This should be the title
</a>
<span id='title_stars_2' name='title_stars_2'> </span>
</h3>
<p>
<span class='url'>www.speed<b>test</b>.net/fr/
</span>
-
<A class="proxy" id="proxy_link" HREF="https://ixquick-proxy.com/do/spg/proxy?ep=&edata=&ek=&ekdata="
class='proxy'>
Navigation avec Ixquick Proxy
</A>
-
<A HREF="https://ixquick-proxy.com/do/spg/highlight.pl?l=francais&c=hf&cat=web&q=test&rl=NONE&rid=
&hlq=https://startpage.com/do/search&mtabp=-1&mtcmd=process_search&mtlanguage=francais&mtengine0=
&mtcat=web&u=http:
%2
F
%2
Fwww.speedtest.net
%2
Ffr
%2
F" class='proxy'>
Mis en surbrillance
</A>
</p>
</li>
"""
response
=
mock
.
Mock
(
text
=
html
.
encode
(
'utf-8'
))
results
=
startpage
.
response
(
response
)
self
.
assertEqual
(
type
(
results
),
list
)
self
.
assertEqual
(
len
(
results
),
1
)
self
.
assertEqual
(
results
[
0
][
'content'
],
''
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment