def testDifficultyOfFeedItems(self):
        feed = RSSFeedRule().feed1
        download_from_feed(feed, zeeguu.core.db.session, 3, False)

        articles = feed.get_articles(limit=2)

        assert len(articles) == 2
        assert articles[0].fk_difficulty
    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, False)

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

        assert (topic in article.topics)
示例#3
0
    def setUp(self):
        super().setUp()

        self.feed1 = RSSFeedRule().feed1

        RSSFeedRegistration.find_or_create(zeeguu.core.db.session, self.user,
                                           self.feed1)
    def testDownloadWithWords(self):
        feed = RSSFeedRule().feed1

        download_from_feed(feed, zeeguu.core.db.session, 3, False)

        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)
示例#5
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
示例#6
0
class FeedTest(ModelTestMixIn, TestCase):
    def setUp(self):
        super().setUp()

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

    def test_feed_items(self):
        assert len(self.spiegel.get_articles()) == 3
        assert len(self.spiegel.get_articles(limit=2)) == 2

    def test_after_date_works(self):
        tomorrow = datetime.now() + timedelta(days=1)
        assert not self.spiegel.get_articles(after_date=tomorrow)

    def test_article_ordering(self):
        ordered_by_difficulty = self.spiegel.get_articles(easiest_first=True)
        assert ordered_by_difficulty[0].fk_difficulty <= ordered_by_difficulty[
            1].fk_difficulty

        ordered_by_time = self.spiegel.get_articles(most_recent_first=True)
        assert ordered_by_time[0].published_time >= ordered_by_time[
            1].published_time
示例#7
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
示例#8
0
    def setUp(self):
        super().setUp()

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