MCPcopy Index your code
hub / github.com/clips/pattern / _test_results

Method _test_results

test/test_web.py:523–548  ·  view source on GitHub ↗
(self, api, source, license, Engine, type=web.SEARCH, query="today", baseline=[6,6,6,0])

Source from the content-addressed store, hash-verified

521 self._test_search_engine("Newsfeed", url, None, web.Newsfeed, query=url, type=web.NEWS)
522
523 def _test_results(self, api, source, license, Engine, type=web.SEARCH, query="today", baseline=[6,6,6,0]):
524 # Assert SearchEngine result content.
525 # We expect to find http:// URL's and descriptions containing the search query.
526 if api == "Yahoo" and license == ("",""):
527 return
528 i1 = 0
529 i2 = 0
530 i3 = 0
531 i4 = 0
532 e = Engine(license=license, language="en", throttle=0.25)
533 for result in e.search(query, type, count=10, cached=False):
534 i1 += int(result.url.startswith("http"))
535 i2 += int(query in result.url.lower())
536 i2 += int(query in result.title.lower())
537 i2 += int(query in result.description.lower())
538 i3 += int(result.language == "en")
539 i4 += int(result.url.endswith(("jpg","png","gif")))
540 #print result.url
541 #print result.title
542 #print result.description
543 #print i1, i2, i3, i4
544 self.assertTrue(i1 >= baseline[0]) # url's starting with "http"
545 self.assertTrue(i2 >= baseline[1]) # query in url + title + description
546 self.assertTrue(i3 >= baseline[2]) # language "en"
547 self.assertTrue(i4 >= baseline[3]) # url's ending with "jpg", "png" or "gif"
548 print "pattern.web.%s.Result(type=%s)" % (api, type.upper())
549
550 def test_results_google(self):
551 self._test_results("Google", *self.api["Google"])

Callers 10

test_results_googleMethod · 0.95
test_results_yahooMethod · 0.95
test_results_bingMethod · 0.95
test_results_twitterMethod · 0.95
test_results_flickrMethod · 0.95
test_results_facebookMethod · 0.95

Calls 1

searchMethod · 0.45

Tested by

no test coverage detected