mirror of https://github.com/searxng/searxng.git
Add a bit of testing to improve coverage
This commit is contained in:
parent
ab273e2faa
commit
0a1a3e7371
|
@ -23,6 +23,10 @@ class TestSwisscowsEngine(SearxTestCase):
|
|||
self.assertTrue('uiLanguage=browser' in params['url'])
|
||||
self.assertTrue('region=browser' in params['url'])
|
||||
|
||||
dicto['category'] = 'images'
|
||||
params = swisscows.request(query, dicto)
|
||||
self.assertIn('image', params['url'])
|
||||
|
||||
def test_response(self):
|
||||
self.assertRaises(AttributeError, swisscows.response, None)
|
||||
self.assertRaises(AttributeError, swisscows.response, [])
|
||||
|
|
|
@ -29,6 +29,13 @@ class TestYahooNewsEngine(SearxTestCase):
|
|||
self.assertIn('en', params['cookies']['sB'])
|
||||
self.assertIn('en', params['url'])
|
||||
|
||||
def test_sanitize_url(self):
|
||||
url = "test.url"
|
||||
self.assertEqual(url, yahoo_news.sanitize_url(url))
|
||||
|
||||
url = "www.yahoo.com/;_ylt=test"
|
||||
self.assertEqual("www.yahoo.com/", yahoo_news.sanitize_url(url))
|
||||
|
||||
def test_response(self):
|
||||
self.assertRaises(AttributeError, yahoo_news.response, None)
|
||||
self.assertRaises(AttributeError, yahoo_news.response, [])
|
||||
|
@ -57,7 +64,17 @@ class TestYahooNewsEngine(SearxTestCase):
|
|||
This is the content
|
||||
</div>
|
||||
</li>
|
||||
<li class="first">
|
||||
<div class="compTitle">
|
||||
<h3>
|
||||
<a class="yschttl spt" target="_blank">
|
||||
</a>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="compText">
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
"""
|
||||
response = mock.Mock(text=html)
|
||||
results = yahoo_news.response(response)
|
||||
|
|
|
@ -91,6 +91,57 @@ class TestYoutubeNoAPIEngine(SearxTestCase):
|
|||
self.assertEqual(results[0]['thumbnail'], 'https://i.ytimg.com/vi/DIVZCPfAOeM/hqdefault.jpg')
|
||||
self.assertTrue('DIVZCPfAOeM' in results[0]['embedded'])
|
||||
|
||||
html = """
|
||||
<ol id="item-section-063864" class="item-section">
|
||||
<li>
|
||||
<div class="yt-lockup yt-lockup-tile yt-lockup-video vve-check clearfix yt-uix-tile"
|
||||
data-context-item-id="DIVZCPfAOeM"
|
||||
data-visibility-tracking="CBgQ3DAYACITCPGXnYau6sUCFZEIHAod-VQASCj0JECx_-GK5uqMpcIB">
|
||||
<div class="yt-lockup-dismissable"><div class="yt-lockup-thumbnail contains-addto">
|
||||
<a aria-hidden="true" href="/watch?v=DIVZCPfAOeM" class=" yt-uix-sessionlink pf-link"
|
||||
data-sessionlink="itct=CBgQ3DAYACITCPGXnYau6sUCFZEIHAod-VQASCj0JFIEdGVzdA">
|
||||
<div class="yt-thumb video-thumb"><img src="//i.ytimg.com/vi/DIVZCPfAOeM/mqdefault.jpg"
|
||||
width="196" height="110"/></div><span class="video-time" aria-hidden="true">11:35</span></a>
|
||||
<span class="thumb-menu dark-overflow-action-menu video-actions">
|
||||
</span>
|
||||
</div>
|
||||
<div class="yt-lockup-content">
|
||||
<h3 class="yt-lockup-title">
|
||||
<span class="accessible-description" id="description-id-259079"> - Durée : 11:35.</span>
|
||||
</h3>
|
||||
<div class="yt-lockup-byline">de
|
||||
<a href="/user/mheejapan" class=" yt-uix-sessionlink spf-link g-hovercard"
|
||||
data-sessionlink="itct=CBgQ3DAYACITCPGXnYau6sUCFZEIHAod-VQASCj0JA" data-ytid="UCzEesu54Hjs0uRKmpy66qeA"
|
||||
data-name="">MEHAY SUPERBIKE</a></div><div class="yt-lockup-meta">
|
||||
<ul class="yt-lockup-meta-info">
|
||||
<li>il y a 20 heures</li>
|
||||
<li>8 424 vues</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="yt-lockup-badges">
|
||||
<ul class="yt-badge-list ">
|
||||
<li class="yt-badge-item" >
|
||||
<span class="yt-badge">Nouveauté</span>
|
||||
</li>
|
||||
<li class="yt-badge-item" ><span class="yt-badge " >HD</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="yt-lockup-action-menu yt-uix-menu-container">
|
||||
<div class="yt-uix-menu yt-uix-videoactionmenu hide-until-delayloaded"
|
||||
data-video-id="DIVZCPfAOeM" data-menu-content-id="yt-uix-videoactionmenu-menu">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
"""
|
||||
response = mock.Mock(text=html)
|
||||
results = youtube_noapi.response(response)
|
||||
self.assertEqual(type(results), list)
|
||||
self.assertEqual(len(results), 1)
|
||||
|
||||
html = """
|
||||
<ol id="item-section-063864" class="item-section">
|
||||
<li>
|
||||
|
|
Loading…
Reference in New Issue