Exemple #1
0
 def test_under_returns_true_if_article_is_in_folder(self):
     info = ArticleInfo(fullname='cooking/madras',
                        category='cooking',
                        slug='madras',
                        extension='txt')
     self.assertTrue(info.under('cooking'))
     self.assertFalse(info.under('reading'))
Exemple #2
0
def _article(fullname, tags, content):
    info = ArticleInfo()
    info.fullname = fullname
    info.tags = tags
    article = Article()
    article.info = info
    article.content = content
    return article
Exemple #3
0
    def test_plugin_processes_content_of_markdown_articles(self):
        with self.app.test_request_context():
            self.app.preprocess_request()

            info = ArticleInfo()
            info.extension = 'md'
            article = Article()
            article.info = info
            article.content = '*stuff*'
            article = self.plugin.on_article_fetch(article)
            self.assertEqual('<p><em>stuff</em></p>', article.content)
Exemple #4
0
    def test_plugin_skips_non_markdown_articles(self):
        with self.app.test_request_context():
            self.app.preprocess_request()

            info = ArticleInfo()
            info.extension = 'html'
            article = Article()
            article.info = info
            article.content = '*stuff*'
            article = self.plugin.on_article_fetch(article)
            self.assertEqual('*stuff*', article.content)
Exemple #5
0
    def test_html_summary_attribute_set_correctly(self):
        with self.app.test_request_context():
            self.app.preprocess_request()

            info = ArticleInfo()
            info.extension = 'md'
            article = Article()
            article.info = info
            article.content = '<p>stuff</p><p>blah hello</p><p>dude the</p><p>east market</p>'
            self.app.config['YAWT_EXCERPT_WORDCOUNT'] = 5
            article = self.plugin.on_article_fetch(article)
        self.assertEqual(Markup('<p>stuff</p><p>blah hello</p><p>dude the</p>'), article.info.summary)
Exemple #6
0
    def test_text_summary_attribute_set_correctly(self):
        with self.app.test_request_context():
            self.app.preprocess_request()

            info = ArticleInfo()
            info.extension = 'md'
            article = Article()
            article.info = info
            article.content = 'stuff blah hello dude the east market'
            self.app.config['YAWT_EXCERPT_WORDCOUNT'] = 5
            article = self.plugin.on_article_fetch(article)
        self.assertEqual('stuff blah hello dude the [...]', article.info.summary)
Exemple #7
0
 def test_raises_error_when_fetching_non_existent_info(self):
     info = ArticleInfo()
     info.fullname = 'cooking/vindaloo'
     self.assertRaises(ArticleNotFoundError,
                       self.store.fetch_article_by_info,
                       info)
Exemple #8
0
 def test_fetch_article_by_info(self):
     info = ArticleInfo()
     info.fullname = 'cooking/madras'
     article = self.store.fetch_article_by_info(info)
     self.assertEquals(info.fullname, article.info.fullname)