summaryrefslogtreecommitdiff
path: root/searx/tests
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2015-05-02 21:08:56 +0200
committerAlexandre Flament <alex@al-f.net>2015-05-03 13:41:36 +0200
commit44ed4424f60533b73f452252f95f1bc00ec48bc8 (patch)
tree1bc1fe2ba2957c8c6e1f81732ea3ab3a251b9019 /searx/tests
parentbbd83f5a519381ac7ea690a1645258d106a9ba8a (diff)
downloadsearxng-44ed4424f60533b73f452252f95f1bc00ec48bc8.tar.gz
searxng-44ed4424f60533b73f452252f95f1bc00ec48bc8.zip
[fix] yahoo_news engine
Diffstat (limited to 'searx/tests')
-rw-r--r--searx/tests/engines/test_yahoo_news.py153
1 files changed, 71 insertions, 82 deletions
diff --git a/searx/tests/engines/test_yahoo_news.py b/searx/tests/engines/test_yahoo_news.py
index 797dc11b7..94d819d61 100644
--- a/searx/tests/engines/test_yahoo_news.py
+++ b/searx/tests/engines/test_yahoo_news.py
@@ -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)