Example #1
0
class TestWebblog(unittest.TestCase):

    def setUp(self):
        self.base = os.path.join(
            os.path.realpath(os.path.dirname(__file__)), "fixtures")
        self.blog = Webblog(self.base, "/tmp")

    def test_posts(self):
        self.assertEqual(self.blog.posts(),
            [os.path.join(self.base, "2012", "05", "08", "baz.rst"),
             os.path.join(self.base, "2012", "05", "02", "foo-bar.rst"),
             os.path.join(self.base, "2012", "05", "01", "lorem-ipsum.rst")])

    def test_latest_posts_with_2_posts(self):
        self.assertEqual(self.blog.latest_posts(2),
            [os.path.join(self.base, "2012", "05", "08", "baz.rst"),
             os.path.join(self.base, "2012", "05", "02", "foo-bar.rst")])

    def test_latest_posts_with_1_post(self):
        self.assertEqual(self.blog.latest_posts(1),
            [os.path.join(self.base, "2012", "05", "08", "baz.rst")])

    def test_posts_archive(self):
        self.assertEqual(self.blog.posts_archive(),
            {"2012/05" :
            [os.path.join(self.base, "2012", "05", "08", "baz.rst"),
             os.path.join(self.base, "2012", "05", "02", "foo-bar.rst"),
             os.path.join(self.base, "2012", "05", "01", "lorem-ipsum.rst")]})
Example #2
0
 def setUp(self):
     self.base = os.path.join(
         os.path.realpath(os.path.dirname(__file__)), "fixtures")
     self.blog = Webblog(self.base, "/tmp")
Example #3
0
#!/usr/bin/env python3

from post import Post
from webblog import Webblog

if __name__ == "__main__":
    wb = Webblog("_posts", "source")
    wb.render_posts()
    wb.render_latest_posts(5)
    wb.render_archive()
Example #4
0
#!/usr/bin/env python

from webblog import Webblog

if __name__ == '__main__':
    wb = Webblog('_posts', 'source')
    wb.render_posts()
    wb.render_latest_posts(4)
    wb.render_archive()