Exemplo n.º 1
0
 def test_articles_skips_short_articles(self):
     extracted_data = MagicMock()
     extracted_data.cleaned_text = 'short full text'
     self.create_patch('argos.core.membrane.extractor.extract_entry_data', return_value=(extracted_data, 'short full text'))
     articles = []
     collector.get_articles(self.feed, lambda a: articles.append(a))
     self.assertEquals(len(articles), 0)
Exemplo n.º 2
0
 def test_articles_skips_unreachable_articles(self):
     from urllib import error
     self.create_patch('argos.core.membrane.extractor.extract_entry_data',
                       side_effect=[error.URLError('unreachable')])
     articles = []
     collector.get_articles(self.feed, lambda a: articles.append(a))
     self.assertEquals(len(articles), 0)
Exemplo n.º 3
0
    def test_articles_ignores_existing(self):
        self.patch_extraction()

        articles = []
        collector.get_articles(self.feed, lambda a: articles.append(a))
        collector.get_articles(self.feed, lambda a: articles.append(a))

        self.assertEquals(Article.query.count(), 1)
Exemplo n.º 4
0
 def test_articles_skips_short_articles(self):
     extracted_data = MagicMock()
     extracted_data.cleaned_text = 'short full text'
     self.create_patch('argos.core.membrane.extractor.extract_entry_data',
                       return_value=(extracted_data, 'short full text'))
     articles = []
     collector.get_articles(self.feed, lambda a: articles.append(a))
     self.assertEquals(len(articles), 0)
Exemplo n.º 5
0
    def test_articles_ignores_existing(self):
        self.patch_extraction()

        articles = []
        collector.get_articles(self.feed, lambda a: articles.append(a))
        collector.get_articles(self.feed, lambda a: articles.append(a))

        self.assertEquals(Article.query.count(), 1)
Exemplo n.º 6
0
 def test_articles_skips_404_articles(self):
     from urllib import error
     self.create_patch('argos.core.membrane.extractor.extract_entry_data',
                       side_effect=[
                           error.HTTPError(url=None,
                                           code=404,
                                           msg=None,
                                           hdrs=None,
                                           fp=None)
                       ])
     articles = []
     collector.get_articles(self.feed, lambda a: articles.append(a))
     self.assertEquals(len(articles), 0)
Exemplo n.º 7
0
    def test_collect_ignores_same_source_and_title_if_urls_differ(self):
        self.patch_extraction()

        articles = []
        collector.get_articles(self.feed, lambda a: articles.append(a))

        # Setup the same article, but with a different link.
        article = {
            'links': [{
                'href': 'http://another_url.com'
            }],
            'title': 'some title',
            'published': 'Thu, 09 Jan 2014 14:00:00 GMT',
            'updated': 'Thu, 09 Jan 2014 14:00:00 GMT'
        }
        data = MagicMock(entries=[article], bozo=False)
        self.mock_parse.return_value = data

        collector.get_articles(self.feed, lambda a: articles.append(a))

        self.assertEquals(Article.query.count(), 1)
Exemplo n.º 8
0
    def test_collect_ignores_same_source_and_title_if_urls_differ(self):
        self.patch_extraction()

        articles = []
        collector.get_articles(self.feed, lambda a: articles.append(a))

        # Setup the same article, but with a different link.
        article = {
                'links': [{'href': 'http://another_url.com'}],
                'title': 'some title',
                'published': 'Thu, 09 Jan 2014 14:00:00 GMT',
                'updated': 'Thu, 09 Jan 2014 14:00:00 GMT'
        }
        data = MagicMock(
                    entries=[article],
                    bozo=False
               )
        self.mock_parse.return_value = data

        collector.get_articles(self.feed, lambda a: articles.append(a))

        self.assertEquals(Article.query.count(), 1)
Exemplo n.º 9
0
 def test_articles_skips_unreachable_articles(self):
     from urllib import error
     self.create_patch('argos.core.membrane.extractor.extract_entry_data', side_effect=[error.URLError('unreachable')])
     articles = []
     collector.get_articles(self.feed, lambda a: articles.append(a))
     self.assertEquals(len(articles), 0)
Exemplo n.º 10
0
 def test_articles_skips_404_articles(self):
     from urllib import error
     self.create_patch('argos.core.membrane.extractor.extract_entry_data', side_effect=[error.HTTPError(url=None, code=404, msg=None, hdrs=None, fp=None)])
     articles = []
     collector.get_articles(self.feed, lambda a: articles.append(a))
     self.assertEquals(len(articles), 0)
Exemplo n.º 11
0
    def test_articles(self):
        self.patch_extraction()

        articles = []
        collector.get_articles(self.feed, lambda a: articles.append(a))
        self.assertEquals(len(articles), 1)
Exemplo n.º 12
0
    def test_articles(self):
        self.patch_extraction()

        articles = []
        collector.get_articles(self.feed, lambda a: articles.append(a))
        self.assertEquals(len(articles), 1)