コード例 #1
0
    def testDifficultyOfFeedItems(self):
        feed = RSSFeedRule().feed1
        download_from_feed(feed, zeeguu_core.db.session, 3)

        articles = feed.get_articles(limit=2)

        assert len(articles) == 2
        assert articles[0].fk_difficulty
コード例 #2
0
ファイル: test_feeds.py プロジェクト: mircealungu/Zeeguu-API
    def test_get_feed_items_with_metrics(self):
        download_from_feed(self.feed1, zeeguu_core.db.session, 3)

        feed_items = self.json_from_api_get(f"get_feed_items_with_metrics/{self.feed1.id}")

        assert len(feed_items) > 0

        assert feed_items[0]["title"]
        assert feed_items[0]["summary"]
        assert feed_items[0]["published"]
        assert feed_items[0]['metrics']
コード例 #3
0
    def test_get_feed_items_with_metrics(self):
        download_from_feed(self.feed1, zeeguu_core.db.session, 3)

        feed_items = self.json_from_api_get(
            f"get_feed_items_with_metrics/{self.feed1.id}"
        )

        assert len(feed_items) > 0

        assert feed_items[0]["title"]
        assert feed_items[0]["summary"]
        assert feed_items[0]["published"]
        assert feed_items[0]["metrics"]
コード例 #4
0
    def testDownloadWithTopic(self):
        feed = RSSFeedRule().feed1
        topic = Topic("Spiegel")
        zeeguu_core.db.session.add(topic)
        zeeguu_core.db.session.commit()
        loc_topic = LocalizedTopic(topic, self.lan, "spiegelDE", "spiegel")
        zeeguu_core.db.session.add(loc_topic)
        zeeguu_core.db.session.commit()

        download_from_feed(feed, zeeguu_core.db.session, 3)

        article = feed.get_articles(limit=2)[0]

        assert (topic in article.topics)
コード例 #5
0
def retrieve_articles_from_all_feeds():
    counter = 0
    all_feeds = RSSFeed.query.all()
    all_feeds_count = len(all_feeds)
    for feed in all_feeds:
        counter += 1
        try:
            msg = f"*** >>>>>>>>> {feed.title} ({counter}/{all_feeds_count}) <<<<<<<<<< "  # .encode('utf-8')
            log("")
            log(f"{msg}")

            download_from_feed(feed, zeeguu_core.db.session)

        except Exception as e:
            traceback.print_exc()
コード例 #6
0
    def testDownloadWithWords(self):
        feed = RSSFeedRule().feed1

        download_from_feed(feed, zeeguu_core.db.session, 3)

        article = feed.get_articles(limit=2)[0]

        # Try two words, as one might be filtered out
        word = strip_article_title_word(article.title.split()[0])
        article_word = ArticleWord.find_by_word(word)

        if word in ['www', ''
                    ] or word.isdigit() or len(word) < 3 or len(word) > 25:
            assert (article_word is None)
        else:
            assert (article in article_word.articles)
コード例 #7
0
def retrieve_articles_from_all_feeds():
    counter = 0
    all_feeds = RSSFeed.query.all()
    all_feeds_count = len(all_feeds)
    for feed in all_feeds:
        counter += 1
        msg = f"{counter}/{all_feeds_count}: DOWNLOADING {feed.title}".encode(
            'utf-8')
        print(msg)
        zeeguu_core.log(msg)

        download_from_feed(feed, zeeguu_core.db.session)

        msg = f"{counter}/{all_feeds_count}: FINISHED DOWNLOADING {feed.title}".encode(
            'utf-8')
        print(msg)
        zeeguu_core.log(msg)
コード例 #8
0
    def setUp(self):
        super().setUp()

        self.spiegel = RSSFeedRule().feed1
        download_from_feed(self.spiegel, self.db.session, 3, False)