Exemplo n.º 1
0
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))
Exemplo n.º 2
0
 def test_local_ma(self):
     news, title = news_source_national.get_most_read('localMA')
     self.assertEqual(len(news), 6)
Exemplo n.º 3
0
 def test_veja(self):
     news, title = news_source_national.get_most_read('veja')
     self.assertEqual(len(news), 10)
Exemplo n.º 4
0
 def test_carta(self):
     news, title = news_source_national.get_most_read('carta')
     self.assertEqual(len(news), 5)
Exemplo n.º 5
0
 def test_r7(self):
     news, title = news_source_national.get_most_read('r7')
     self.assertEqual(len(news), 7)
Exemplo n.º 6
0
 def test_g1(self):
     news, title = news_source_national.get_most_read('g1')
     self.assertEqual(len(news), 5)
Exemplo n.º 7
0
 def test_local_to(self):
     news, title = news_source_national.get_most_read('localTO')
     self.assertEqual(len(news), 5)