class TestYahooSearch(unittest.TestCase): def setUp(self): self.ys = YahooSearch('"query text"') fixture_path = normpath( join(dirname(__file__), ('../../../../tests/' 'fixtures/search/yahooSearch.json'))) self.fixture = open(fixture_path) self.page = simplejson.load(self.fixture) self.results = self.ys._extract_raw_results_list(self.page) def tearDown(self): self.fixture.close() def test_extract_info(self): search_info = self.ys._extract_info(self.page) self.failUnless(search_info['to'] == 5, 'Wrong "to" field') self.failUnless(search_info['from'] == 1, 'Wrong "from" field') self.failUnless(search_info['total'] == 15486, 'Wrong total field') def test_extract_result(self): result = self.ys._extract_result(self.results[0]) self.failUnless(result.title.startswith('the_gdf : ')) self.failUnless(result.url == ('http://groups.yahoo.com/group/the_gdf' '/message/21494?l=1')) self.failUnless(result.desc.startswith('Re: <b>Some query'))
def setUp(self): self.ys = YahooSearch('"query text"') fixture_path = normpath( join(dirname(__file__), ('../../../../tests/' 'fixtures/search/yahooSearch.json'))) self.fixture = open(fixture_path) self.page = simplejson.load(self.fixture) self.results = self.ys._extract_raw_results_list(self.page)
def setUp(self): self.ys = YahooSearch('"query text"') fixture_path = normpath(join(dirname(__file__), ('../../../../tests/' 'fixtures/search/yahooSearch.json'))) self.fixture = open(fixture_path) self.page = simplejson.load(self.fixture) self.results = self.ys._extract_raw_results_list(self.page)
def create_searcher(self, engine): if engine == Searcher.GOOGLE: return GoogleJSONSearch() elif engine == Searcher.SCHOLAR: return ScholarSearch() elif engine == Searcher.BING: return BingSearch() elif engine == Searcher.YAHOO: return YahooSearch() else: raise UtilCreationError('Requested searcher is not available')
class TestYahooSearch(unittest.TestCase): def setUp(self): self.ys = YahooSearch('"query text"') fixture_path = normpath(join(dirname(__file__), ('../../../../tests/' 'fixtures/search/yahooSearch.json'))) self.fixture = open(fixture_path) self.page = simplejson.load(self.fixture) self.results = self.ys._extract_raw_results_list(self.page) def tearDown(self): self.fixture.close() def test_extract_info(self): search_info = self.ys._extract_info(self.page) self.failUnless(search_info['to'] == 5, 'Wrong "to" field') self.failUnless(search_info['from'] == 1, 'Wrong "from" field') self.failUnless(search_info['total'] == 15486, 'Wrong total field') def test_extract_result(self): result = self.ys._extract_result(self.results[0]) self.failUnless(result.title.startswith('the_gdf : ')) self.failUnless(result.url == ('http://groups.yahoo.com/group/the_gdf' '/message/21494?l=1')) self.failUnless(result.desc.startswith('Re: <b>Some query'))