@@ -0,0 +1,2250 @@
+%22%22%22%0Atest.test_builder%0A~~~~~~~~~~~~~~~~~%0A%0AThis is the unit test file for site builder.%0A%0A:Copyright: Copyright 2014 Yang LIU %3Czesikliu@gmail.com%3E%0A:License: BSD, see LICENSE for details.%0A%22%22%22%0A%0Aimport unittest%0Aimport datetime%0Aimport io%0A%0Afrom zkb.builder import FileProcessor, SiteBuilder%0Afrom zkb.config import SiteConfig%0A%0A%0Aclass TestSiteBuilder(unittest.TestCase):%0A    class MockFileProcessor(FileProcessor):%0A        def get_article_files(self, dirname, ignored_dirs=None):%0A            return %5B('article1.md', 'article1', datetime.datetime(2002, 1, 5),%0A                     'yaml', None),%0A                    ('article2.md', 'article2', datetime.datetime(2002, 2, 1),%0A                     'yaml', None),%0A                    ('article2.md', 'article2', datetime.datetime(2002, 3, 1),%0A                     'yaml', None)%5D%0A%0A        def read(self, filename):%0A            output = io.BytesIO()%0A            if filename == 'article1.md':%0A                data = (u'title: Test%5Cn'%0A                        u'tag: tag1%5Cn'%0A                        u'%5CnContent')%0A            elif filename == 'article2.md':%0A                data = (u'title: Test2%5Cn'%0A                        u'tag: tag1, tag2%5Cn'%0A                        u'%5CnContent')%0A            else:%0A                data = (u'title: Test3%5Cn'%0A                        u'date: 2002/1/30%5Cn'%0A                        u'tag: tag2, tag3%5Cn'%0A                        u'%5CnContent')%0A            output.write(data.encode('utf-8', 'replace'))%0A            return output%0A%0A        def write(self, filename, encoding, content):%0A            pass%0A%0A        def write_stream(self, filename, stream):%0A            pass%0A%0A        def copy_file(self, source, destination):%0A            pass%0A%0A        def exists(self, file):%0A            return True%0A%0A    class MockSiteBuilder(SiteBuilder):%0A        def _do_build(self):%0A            return self.config%0A%0A    def test_site_builder(self):%0A        config = SiteConfig()%0A        config.site_builder = %22test.test_builder/%22 %5C%0A                              %22TestSiteBuilder.MockSiteBuilder%22%0A        config = SiteBuilder.from_config(%0A            config, TestSiteBuilder.MockFileProcessor()).build()%0A        self.assertEqual(len(config.articles_by_date), 3,%0A                         'article count mismatch')%0A%0A%0A

Add a skeleton of builder test.