Esempio n. 1
0
    def setUp(self):
        super().setUp()

        self.feed1 = RSSFeedRule().feed1

        RSSFeedRegistration.find_or_create(
            zeeguu_core.db.session, self.user, self.feed1
        )
Esempio n. 2
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
Esempio n. 3
0
    def test_start_following_feed(self):
        new_feed_id = RSSFeedRule().feed.id

        # When
        form_data = {"source_id": new_feed_id}
        self.api_post(f"/{START_FOLLOWING_FEED}", form_data)

        # Then
        followed_feed_ids = [
            each["id"] for each in self.json_from_api_get(f"/{FOLLOWED_FEEDS}")
        ]
        assert new_feed_id in followed_feed_ids
Esempio n. 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)
Esempio n. 5
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)
Esempio n. 6
0
    def _create_model_object(self):
        title = " ".join(self.faker.text().split()[:4])
        authors = self.faker.name()
        content = self.faker.text()
        summary = self.faker.text()
        published = datetime.now() - timedelta(minutes=randint(0, 7200))
        rss_feed = RSSFeedRule().feed
        language = LanguageRule().random
        url = UrlRule().url

        article = Article(url, title, authors, content, summary, published,
                          rss_feed, language)

        if self._exists_in_db(article):
            return self._create_model_object()

        return article
Esempio n. 7
0
    def setUp(self):
        super().setUp()

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