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
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)
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)
def setUp(self): super().setUp() self.feed1 = RSSFeedRule().feed1 RSSFeedRegistration.find_or_create( zeeguu_core.db.session, self.user, self.feed1 )
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
class FeedTest(ModelTestMixIn, TestCase): def setUp(self): super().setUp() self.spiegel = RSSFeedRule().feed1 download_from_feed(self.spiegel, self.db.session, 3) 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
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
def setUp(self): super().setUp() self.spiegel = RSSFeedRule().feed1 download_from_feed(self.spiegel, self.db.session, 3, False)