Ejemplo n.º 1
0
    def setUp(self):
        wiki_path = os.path.join(test_path, 'mywiki_for_others')

        self.expected_config = get_default_config()
        self.expected_config.update({
            "author":
            "Tanky Woo",
            "debug":
            True,
            "default_ext":
            "markdown",
            "description":
            "This is a simiki's config sample,"
            " \u6d4b\u8bd5\u6837\u4f8b",
            "destination":
            "destination",
            "keywords":
            "wiki, simiki, python, \u7ef4\u57fa",
            "root":
            "/wiki/",
            "source":
            "source",
            "attach":
            "attach",
            "theme":
            "mytheme",
            "themes_dir":
            "simiki_themes",
            "title":
            "\u6211\u7684Wiki",
            "url":
            "http://wiki.tankywoo.com"
        })
        self.config_file = os.path.join(wiki_path, "config_sample.yml")
Ejemplo n.º 2
0
    def test_get_template_vars(self):
        src_file = os.path.join(self.wiki_path, 'content', 'foo目录',
                                'foo_page_中文.md')
        self.generator.src_file = src_file
        meta, content = self.generator.get_meta_and_content()
        template_vars = self.generator.get_template_vars(meta, content)
        expected_template_vars = {
            u'page': {
                u'category': u'foo\u76ee\u5f55',
                u'content': u'<p>[[simiki]]</p>\n'
                            '<p>Simiki is a simple wiki '
                            'framework, written in Python.</p>'
                            '\n<p>Line 1<br />\nLine 2</p>',
                u'filename': u'foo_page_\u4e2d\u6587.html',
                u'date': '2013-10-17 00:03',
                u'layout': 'page',
                u'relation': [],
                u'title': 'Foo Page 2'
            },
            u'site': get_default_config()
        }

        expected_template_vars['site'].update({'root': ''})
        template_vars['site'].pop('time')
        expected_template_vars['site'].pop('time')
        assert template_vars == expected_template_vars
Ejemplo n.º 3
0
    def setUp(self):
        self.default_config = get_default_config()

        self.wiki_path = os.path.join(test_path, 'mywiki_for_generator')

        os.chdir(self.wiki_path)

        self.config_file = os.path.join(base_path, 'simiki', 'conf_templates',
                                        '_config.yml.in')

        self.config = parse_config(self.config_file)

        s_themes_path = os.path.join(base_path, 'simiki',
                                     self.default_config['themes_dir'])
        self.d_themes_path = os.path.join('./',
                                          self.default_config['themes_dir'])
        if os.path.exists(self.d_themes_path):
            shutil.rmtree(self.d_themes_path)
        copytree(s_themes_path, self.d_themes_path)

        self.pages = {
            'content/other/page1.md': {
                'content': '',
                'collection': 'mycoll',
                'date': '2016-06-02 00:00',
                'layout': 'page',
                'title': 'Page 1'
            },
            'content/other/page2.md': {
                'content': '',
                'date': '2016-06-02 00:00',
                'layout': 'page',
                'title': 'Page 2'
            },
            'content/other/page3.md': {
                'content': '',
                'collection': 'mycoll',
                'date': '2016-06-02 00:00',
                'layout': 'page',
                'title': 'Page 3'
            },
        }

        self.generator = CatalogGenerator(self.config, self.wiki_path,
                                          self.pages)
Ejemplo n.º 4
0
    def setUp(self):
        self.default_config = get_default_config()

        self.wiki_path = os.path.join(test_path, "mywiki_for_generator")

        os.chdir(self.wiki_path)

        self.config_file = os.path.join(base_path, "simiki", "conf_templates", "_config.yml.in")

        self.config = parse_config(self.config_file)

        s_themes_path = os.path.join(base_path, "simiki", self.default_config["themes_dir"])
        self.d_themes_path = os.path.join("./", self.default_config["themes_dir"])
        if os.path.exists(self.d_themes_path):
            shutil.rmtree(self.d_themes_path)
        copytree(s_themes_path, self.d_themes_path)

        self.generator = PageGenerator(self.config, self.wiki_path)
Ejemplo n.º 5
0
    def setUp(self):
        self.default_config = get_default_config()

        self.wiki_path = os.path.join(test_path, 'mywiki_for_others')
        os.chdir(self.wiki_path)

        self.kwargs = {'themes_dir': 'themes'}
        self.original_fabfile = os.path.join(base_path, 'simiki',
                                             'conf_templates', 'fabfile.py')
        self.local_fabfile = os.path.join(self.wiki_path, 'fabfile.py')

        self.original_theme = os.path.join(base_path, 'simiki',
                                           self.default_config['themes_dir'],
                                           self.default_config['theme'])
        self.local_theme = os.path.join(self.wiki_path,
                                        self.default_config['themes_dir'],
                                        self.default_config['theme'])

        self.local_theme_afile = os.path.join(self.local_theme, 'base.html')
Ejemplo n.º 6
0
    def setUp(self):
        self.default_config = get_default_config()

        self.wiki_path = os.path.join(test_path, 'mywiki_for_others')
        os.chdir(self.wiki_path)

        self.kwargs = {'themes_dir': 'themes'}
        self.original_fabfile = os.path.join(base_path, 'simiki',
                                             'conf_templates', 'fabfile.py')
        self.local_fabfile = os.path.join(self.wiki_path, 'fabfile.py')

        self.original_theme = os.path.join(base_path, 'simiki',
                                           self.default_config['themes_dir'],
                                           self.default_config['theme'])
        self.local_theme = os.path.join(self.wiki_path,
                                        self.default_config['themes_dir'],
                                        self.default_config['theme'])

        self.local_theme_afile = os.path.join(self.local_theme, 'base.html')
Ejemplo n.º 7
0
    def setUp(self):
        self.default_config = get_default_config()

        self.wiki_path = os.path.join(test_path, 'mywiki_for_generator')

        os.chdir(self.wiki_path)

        self.config_file = os.path.join(base_path, 'simiki',
                                        'conf_templates', '_config.yml.in')

        self.config = parse_config(self.config_file)

        s_themes_path = os.path.join(base_path, 'simiki',
                                     self.default_config['themes_dir'])
        self.d_themes_path = os.path.join('./',
                                          self.default_config['themes_dir'])
        if os.path.exists(self.d_themes_path):
            shutil.rmtree(self.d_themes_path)
        copytree(s_themes_path, self.d_themes_path)

        self.pages = {
            'content/other/page1.md':
                {'content': '',
                 'collection': 'mycoll',
                 'date': '2016-06-02 00:00',
                 'layout': 'page',
                 'title': 'Page 1'},
            'content/other/page2.md':
                {'content': '',
                 'date': '2016-06-02 00:00',
                 'layout': 'page',
                 'title': 'Page 2'},
            'content/other/page3.md':
                {'content': '',
                 'collection': 'mycoll',
                 'date': '2016-06-02 00:00',
                 'layout': 'page',
                 'title': 'Page 3'},
        }

        self.generator = CatalogGenerator(self.config, self.wiki_path,
                                          self.pages)
Ejemplo n.º 8
0
    def setUp(self):
        self.default_config = get_default_config()
        self.args = deepcopy(INIT_ARGS)
        self.target_path = "_build"

        if os.path.exists(self.target_path):
            shutil.rmtree(self.target_path)
        self.files = [
            "_config.yml",
            "fabfile.py",
            os.path.join(self.default_config["source"], "intro", "gettingstarted.md"),
            os.path.join(self.default_config["themes_dir"], self.default_config["theme"], "page.html"),
            os.path.join(self.default_config["themes_dir"], self.default_config["theme"], "static", "css", "style.css"),
        ]
        self.dirs = [
            self.default_config["source"],
            self.default_config["destination"],
            self.default_config["themes_dir"],
            os.path.join(self.default_config["themes_dir"], self.default_config["theme"]),
        ]
Ejemplo n.º 9
0
 def setUp(self):
     self.expected_config = get_default_config()
     self.expected_config.update({
         "author": "Tanky Woo",
         "debug": True,
         "default_ext": "markdown",
         "description": "This is a simiki's config sample, \u6d4b\u8bd5\u6837\u4f8b",
         "destination": "destination",
         "keywords": "wiki, simiki, python, \u7ef4\u57fa",
         "root": "/wiki/",
         "source": "source",
         "attach": "attach",
         "theme": "mytheme",
         "themes_dir": "simiki_themes",
         "title": "\u6211\u7684Wiki",
         "url": "http://wiki.tankywoo.com"
     })
     self.config_file = os.path.join(
         os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
         "tests", "configs", "config_sample.yml")
Ejemplo n.º 10
0
    def setUp(self):
        self.default_config = get_default_config()

        self.wiki_path = os.path.join(test_path, 'mywiki_for_generator')

        os.chdir(self.wiki_path)

        self.config_file = os.path.join(base_path, 'simiki',
                                        'conf_templates', '_config.yml.in')

        self.config = parse_config(self.config_file)

        s_themes_path = os.path.join(base_path, 'simiki',
                                     self.default_config['themes_dir'])
        self.d_themes_path = os.path.join('./',
                                          self.default_config['themes_dir'])
        if os.path.exists(self.d_themes_path):
            shutil.rmtree(self.d_themes_path)
        copytree(s_themes_path, self.d_themes_path)

        self.generator = PageGenerator(self.config, self.wiki_path)
Ejemplo n.º 11
0
    def setUp(self):
        self.default_config = get_default_config()

        self.wiki_path = os.path.join(test_path, 'mywiki_for_generator')

        os.chdir(self.wiki_path)

        self.config_file = os.path.join(base_path, 'simiki', 'conf_templates',
                                        '_config.yml.in')

        self.config = parse_config(self.config_file)

        s_themes_path = os.path.join(base_path, 'simiki',
                                     self.default_config['themes_dir'])
        self.d_themes_path = os.path.join('./',
                                          self.default_config['themes_dir'])
        if os.path.exists(self.d_themes_path):
            shutil.rmtree(self.d_themes_path)
        copytree(s_themes_path, self.d_themes_path)

        self.generator = PageGenerator(self.config, self.wiki_path)
Ejemplo n.º 12
0
 def setUp(self):
     BASE_DIR = os.path.join(os.path.dirname(__file__), '..')
     self.default_config = get_default_config()
     self.config_file = os.path.join(BASE_DIR, "simiki", "conf_templates",
                                     "_config.yml.in")
     self.target_path = os.path.join(BASE_DIR, "tests", "_build")
     if os.path.exists(self.target_path):
         shutil.rmtree(self.target_path)
     self.files = [
         "_config.yml",
         "fabfile.py",
         os.path.join(self.default_config['source'], "intro",
                      "gettingstarted.md"),
     ]
     self.dirs = [
         self.default_config['source'],
         self.default_config['destination'],
         self.default_config['themes_dir'],
         os.path.join(self.default_config['themes_dir'],
                      self.default_config['theme']),
     ]
Ejemplo n.º 13
0
 def setUp(self):
     BASE_DIR = os.path.join(os.path.dirname(__file__), '..')
     self.default_config = get_default_config()
     self.config_file = os.path.join(BASE_DIR, "simiki", "conf_templates",
                                     "_config.yml.in")
     self.target_path = os.path.join(BASE_DIR, "tests", "_build")
     if os.path.exists(self.target_path):
         shutil.rmtree(self.target_path)
     self.files = [
         "_config.yml",
         "fabfile.py",
         os.path.join(self.default_config['source'], "intro",
                      "gettingstarted.md"),
     ]
     self.dirs = [
         self.default_config['source'],
         self.default_config['destination'],
         self.default_config['themes_dir'],
         os.path.join(self.default_config['themes_dir'],
                      self.default_config['theme']),
     ]
Ejemplo n.º 14
0
    def test_get_template_vars(self):
        src_file_path = os.path.join(TESTS_ROOT, 'content', 'foo目录',
                                     'foo_page_中文.md')
        generator = PageGenerator(self.config, self.base_path, src_file_path)
        meta, content = generator.get_meta_and_content()
        template_vars = generator.get_template_vars(meta, content)
        expected_template_vars = {
            u'page': {
                u'category': u'foo\u76ee\u5f55',
                u'content': u'<p>Simiki is a simple wiki '
                            'framework, written in Python.</p>',
                'date': '2013-10-17 00:03',
                'layout': 'page',
                'title': 'Foo Page 2'
            },
            u'site': get_default_config()
        }

        expected_template_vars['site'].update({'root': ''})
        template_vars['site'].pop('time')
        expected_template_vars['site'].pop('time')
        assert template_vars == expected_template_vars
Ejemplo n.º 15
0
    def test_get_template_vars(self):
        src_file = os.path.join(self.wiki_path, "content", "foo目录", "foo_page_中文.md")
        self.generator.src_file = src_file
        meta, content = self.generator.get_meta_and_content()
        template_vars = self.generator.get_template_vars(meta, content)
        expected_template_vars = {
            "page": {
                "category": "foo\u76ee\u5f55",
                "content": "<p>Simiki is a simple wiki " "framework, written in Python.</p>",
                "filename": "foo_page_\u4e2d\u6587.html",
                "date": "2013-10-17 00:03",
                "layout": "page",
                "relation": [],
                "title": "Foo Page 2",
            },
            "site": get_default_config(),
        }

        expected_template_vars["site"].update({"root": ""})
        template_vars["site"].pop("time")
        expected_template_vars["site"].pop("time")
        assert template_vars == expected_template_vars
Ejemplo n.º 16
0
    def test_get_template_vars(self):
        src_file_path = os.path.join(TESTS_ROOT, 'content', 'foo目录',
                                     'foo_page_中文.md')
        generator = PageGenerator(self.config, self.base_path, src_file_path)
        meta, content = generator.get_meta_and_content()
        template_vars = generator.get_template_vars(meta, content)
        expected_template_vars = {
            u'page': {
                u'category': u'foo\u76ee\u5f55',
                u'content': u'<p>Simiki is a simple wiki '
                'framework, written in Python.</p>',
                'date': '2013-10-17 00:03',
                'layout': 'page',
                'title': 'Foo Page 2'
            },
            u'site': get_default_config()
        }

        expected_template_vars['site'].update({'root': ''})
        template_vars['site'].pop('time')
        expected_template_vars['site'].pop('time')
        assert template_vars == expected_template_vars
Ejemplo n.º 17
0
    def setUp(self):
        self.default_config = get_default_config()

        self.wiki_path = os.path.join(test_path, "mywiki_for_generator")

        os.chdir(self.wiki_path)

        self.config_file = os.path.join(base_path, "simiki", "conf_templates", "_config.yml.in")

        self.config = parse_config(self.config_file)

        s_themes_path = os.path.join(base_path, "simiki", self.default_config["themes_dir"])
        self.d_themes_path = os.path.join("./", self.default_config["themes_dir"])
        if os.path.exists(self.d_themes_path):
            shutil.rmtree(self.d_themes_path)
        copytree(s_themes_path, self.d_themes_path)

        self.pages = {
            "content/other/page1.md": {
                "content": "",
                "collection": "mycoll",
                "date": "2016-06-02 00:00",
                "layout": "page",
                "title": "Page 1",
            },
            "content/other/page2.md": {"content": "", "date": "2016-06-02 00:00", "layout": "page", "title": "Page 2"},
            "content/other/page3.md": {
                "content": "",
                "collection": "mycoll",
                "date": "2016-06-02 00:00",
                "layout": "page",
                "title": "Page 3",
            },
        }

        self.generator = CatalogGenerator(self.config, self.wiki_path, self.pages)
Ejemplo n.º 18
0
    def setUp(self):
        self.default_config = get_default_config()
        self.args = deepcopy(INIT_ARGS)
        self.target_path = "_build"

        if os.path.exists(self.target_path):
            shutil.rmtree(self.target_path)
        self.files = [
            "_config.yml", "fabfile.py",
            os.path.join(self.default_config['source'], "intro",
                         "gettingstarted.md"),
            os.path.join(self.default_config['themes_dir'],
                         self.default_config['theme'], "page.html"),
            os.path.join(self.default_config['themes_dir'],
                         self.default_config['theme'], "static", "css",
                         "style.css")
        ]
        self.dirs = [
            self.default_config['source'],
            self.default_config['destination'],
            self.default_config['themes_dir'],
            os.path.join(self.default_config['themes_dir'],
                         self.default_config['theme']),
        ]