def test_request(self): yahoo.supported_languages = ['en', 'fr', 'zh-CHT', 'zh-CHS'] query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 1 dicto['language'] = 'fr-FR' params = yahoo.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) self.assertIn('search.yahoo.com', params['url']) self.assertIn('fr', params['url']) self.assertIn('cookies', params) self.assertIn('sB', params['cookies']) self.assertIn('fr', params['cookies']['sB']) dicto['language'] = 'zh' params = yahoo.request(query, dicto) self.assertIn('zh_chs', params['url']) self.assertIn('zh_chs', params['cookies']['sB']) dicto['language'] = 'zh-TW' params = yahoo.request(query, dicto) self.assertIn('zh_cht', params['url']) self.assertIn('zh_cht', params['cookies']['sB']) dicto['language'] = 'all' params = yahoo.request(query, dicto) self.assertIn('cookies', params) self.assertIn('sB', params['cookies']) self.assertIn('en', params['cookies']['sB']) self.assertIn('en', params['url'])
def test_request(self): yahoo.supported_languages = ['en', 'fr', 'zh-CHT', 'zh-CHS'] query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 1 dicto['time_range'] = '' dicto['language'] = 'fr-FR' params = yahoo.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) self.assertIn('search.yahoo.com', params['url']) self.assertIn('fr', params['url']) self.assertIn('cookies', params) self.assertIn('sB', params['cookies']) self.assertIn('fr', params['cookies']['sB']) dicto['language'] = 'zh' params = yahoo.request(query, dicto) self.assertIn('zh_chs', params['url']) self.assertIn('zh_chs', params['cookies']['sB']) dicto['language'] = 'zh-TW' params = yahoo.request(query, dicto) self.assertIn('zh_cht', params['url']) self.assertIn('zh_cht', params['cookies']['sB'])
def test_request(self): query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 1 dicto['language'] = 'fr_FR' params = yahoo.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) self.assertIn('search.yahoo.com', params['url']) self.assertIn('fr', params['url']) self.assertIn('cookies', params) self.assertIn('sB', params['cookies']) self.assertIn('fr', params['cookies']['sB']) dicto['language'] = 'all' params = yahoo.request(query, dicto) self.assertIn('cookies', params) self.assertIn('sB', params['cookies']) self.assertIn('en', params['cookies']['sB']) self.assertIn('en', params['url'])
def test_no_url_in_request_year_time_range(self): dicto = defaultdict(dict) query = 'test_query' dicto['time_range'] = 'year' params = yahoo.request(query, dicto) self.assertEqual({}, params['url'])