[fix] yahoo_news engine

This commit is contained in:
Alexandre Flament 2015-05-02 21:08:56 +02:00
parent bbd83f5a51
commit 44ed4424f6
2 changed files with 89 additions and 89 deletions

View file

@ -39,19 +39,24 @@ class TestYahooNewsEngine(SearxTestCase):
self.assertEqual(yahoo_news.response(response), [])
html = """
<div class="res">
<div>
<h3>
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
This is
the <b>title</b>...
</a>
</h3>
</div>
<span class="url">Business via Yahoo! Finance</span> &nbsp; <span class="timestamp">Feb 03 09:45am</span>
<div class="abstr">
This is the content
</div>
<ol class=" reg searchCenterMiddle">
<li class="first">
<div class="compTitle">
<h3>
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
This is
the <b>title</b>...
</a>
</h3>
</div>
<div>
<span class="cite">Business via Yahoo!</span>
<span class="tri fc-2nd ml-10">May 01 10:00 AM</span>
</div>
<div class="compText">
This is the content
</div>
</li>
</div>
"""
response = mock.Mock(text=html)
@ -63,48 +68,59 @@ class TestYahooNewsEngine(SearxTestCase):
self.assertEqual(results[0]['content'], 'This is the content')
html = """
<div class="res">
<div>
<h3>
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
This is
the <b>title</b>...
</a>
</h3>
</div>
<span class="url">Business via Yahoo!</span> &nbsp; <span class="timestamp">2 hours, 22 minutes ago</span>
<div class="abstr">
This is the content
</div>
</div>
<div class="res">
<div>
<h3>
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
This is
the <b>title</b>...
</a>
</h3>
</div>
<span class="url">Business via Yahoo!</span> &nbsp; <span class="timestamp">22 minutes ago</span>
<div class="abstr">
This is the content
</div>
</div>
<div class="res">
<div>
<h3>
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
This is
the <b>title</b>...
</a>
</h3>
</div>
<span class="url">Business via Yahoo!</span> &nbsp; <span class="timestamp">Feb 03 09:45am 1900</span>
<div class="abstr">
This is the content
</div>
</div>
<ol class=" reg searchCenterMiddle">
<li class="first">
<div class="compTitle">
<h3>
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
This is
the <b>title</b>...
</a>
</h3>
</div>
<div>
<span class="cite">Business via Yahoo!</span>
<span class="tri fc-2nd ml-10">2 hours, 22 minutes ago</span>
</div>
<div class="compText">
This is the content
</div>
</li>
<li>
<div class="compTitle">
<h3>
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
This is
the <b>title</b>...
</a>
</h3>
</div>
<div>
<span class="cite">Business via Yahoo!</span>
<span class="tri fc-2nd ml-10">22 minutes ago</span>
</div>
<div class="compText">
This is the content
</div>
</li>
<li>
<div class="compTitle">
<h3>
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
This is
the <b>title</b>...
</a>
</h3>
</div>
<div>
<span class="cite">Business via Yahoo!</span>
<span class="tri fc-2nd ml-10">Feb 03 09:45AM 1900</span>
</div>
<div class="compText">
This is the content
</div>
</li>
</ol>
"""
response = mock.Mock(text=html)
results = yahoo_news.response(response)
@ -114,30 +130,3 @@ class TestYahooNewsEngine(SearxTestCase):
self.assertEqual(results[0]['url'], 'http://this.is.the.url/')
self.assertEqual(results[0]['content'], 'This is the content')
self.assertEqual(results[2]['publishedDate'].year, datetime.now().year)
html = """
<li class="b_algo" u="0|5109|4755453613245655|UAGjXgIrPH5yh-o5oNHRx_3Zta87f_QO">
<div Class="sa_mc">
<div class="sb_tlst">
<h2>
<a href="http://this.should.be.the.link/" h="ID=SERP,5124.1">
<strong>This</strong> should be the title</a>
</h2>
</div>
<div class="sb_meta">
<cite>
<strong>this</strong>.meta.com</cite>
<span class="c_tlbxTrg">
<span class="c_tlbxH" H="BASE:CACHEDPAGEDEFAULT" K="SERP,5125.1">
</span>
</span>
</div>
<p>
<strong>This</strong> should be the content.</p>
</div>
</li>
"""
response = mock.Mock(text=html)
results = yahoo_news.response(response)
self.assertEqual(type(results), list)
self.assertEqual(len(results), 0)