def get_most_read(key): """ Gets the most read news from a given page (national or international) :param key: the key of the source page (e.g: g1, localDF, WP, etc.) :return: a list with the most read news from the page """ # Check if the News Source is national or internacional if key in news_source_national.strategies: return news_source_national.get_most_read(key) elif key in news_source_international.strategies: return news_source_international.get_most_read(key) elif key in news_source_sports.strategies: return news_source_sports.get_most_read(key) elif key in news_source_entertainment.strategies: return news_source_entertainment.get_most_read(key) elif key in news_source_technology.strategies: return news_source_technology.get_most_read(key) elif key in news_source_music.strategies: return news_source_music.get_most_read(key) elif key in news_source_reddit.strategies: return news_source_reddit.get_most_read(key) else: raise ValueError('No news source found for SOURCE={0}'.format(key))
def test_gp(self): news, title = nss.get_most_read('e_gp') self.assertEqual(len(news), 5)
def test_lance(self): news, title = nss.get_most_read('e_lance') self.assertEqual(len(news), 5)
def test_placar(self): news, title = nss.get_most_read('e_placar') self.assertEqual(len(news), 5)
def test_fox(self): news, title = nss.get_most_read('e_fox_br') self.assertEqual(len(news), 11)
def test_espn(self): news, title = nss.get_most_read('e_espn_br') self.assertEqual(len(news), 6)
def test_fox(self): news, title = nss.get_most_read('e_fox_br') self.assertEqual(len(news), 10)