# Path: simiki/utils.py
# COLOR_CODES = {
#     "reset": "\033[0m",
#     "black": "\033[1;30m",
#     "red": "\033[1;31m",
#     "green": "\033[1;32m",
#     "yellow": "\033[1;33m",
#     "blue": "\033[1;34m",
#     "magenta": "\033[1;35m",
#     "cyan": "\033[1;36m",
#     "white": "\033[1;37m",
#     "bgred": "\033[1;41m",
#     "bggrey": "\033[1;100m",
# }
# def color_msg(color, msg):
# def check_extension(filename):
# def copytree(src, dst, symlinks=False, ignore=None):
# def emptytree(directory, exclude_list=None):
# def mkdir_p(path):
# def listdir_nohidden(path):
# def write_file(filename, content):
# def get_md5(filename):
# def get_dir_md5(dirname):
# def import_string(import_name, silent=False):


import os
import os.path
import unittest
from simiki import utils

class TestUtils(unittest.TestCase):

    def setUp(self):
        wiki_path = os.path.join(test_path, 'mywiki_for_others')
        os.chdir(wiki_path)
        self.content = 'content'
        self.output = 'output'
        if os.path.exists(self.output):
            utils.emptytree(self.output)
            os.rmdir(self.output)

    def test_check_extension(self):
        valid_files = ['/tmp/file1.md', '/tmp/file2.mkd', '/tmp/文件3.mdown',
                       '/tmp/文件4.markdown', '/tmp/目录/文件5.md']
        for f in valid_files:
            assert utils.check_extension(f)

        invalid_files = ['/tmp/file6.txt', '/tmp/目录/文件7.mkdown']
        for f in invalid_files:
            assert not utils.check_extension(f)

    def test_copytree_common(self):
        utils.copytree(self.content, self.output)
        assert os.path.exists(self.output) and os.path.isdir(self.output)

        files = [
            os.path.join('python', 'zen_of_python.md'),
            os.path.join('python', 'python文档.md'),
            os.path.join('其它', 'helloworld.markdown'),

# Path: simiki/utils.py
# COLOR_CODES = {
#     "reset": "\033[0m",
#     "black": "\033[1;30m",
#     "red": "\033[1;31m",
#     "green": "\033[1;32m",
#     "yellow": "\033[1;33m",
#     "blue": "\033[1;34m",
#     "magenta": "\033[1;35m",
#     "cyan": "\033[1;36m",
#     "white": "\033[1;37m",
#     "bgred": "\033[1;41m",
#     "bggrey": "\033[1;100m",
# }
# def color_msg(color, msg):
# def check_extension(filename):
# def copytree(src, dst, symlinks=False, ignore=None):
# def emptytree(directory, exclude_list=None):
# def mkdir_p(path):
# def listdir_nohidden(path):
# def write_file(filename, content):
# def get_md5(filename):
# def get_dir_md5(dirname):
# def import_string(import_name, silent=False):


# Path: tests/test_utils.py
import os
import os.path
import unittest
from simiki import utils


class TestUtils(unittest.TestCase):

    def setUp(self):
        wiki_path = os.path.join(test_path, 'mywiki_for_others')
        os.chdir(wiki_path)
        self.content = 'content'
        self.output = 'output'
        if os.path.exists(self.output):
            utils.emptytree(self.output)
            os.rmdir(self.output)

    def test_check_extension(self):
        valid_files = ['/tmp/file1.md', '/tmp/file2.mkd', '/tmp/文件3.mdown',
                       '/tmp/文件4.markdown', '/tmp/目录/文件5.md']
        for f in valid_files:
            assert utils.check_extension(f)

        invalid_files = ['/tmp/file6.txt', '/tmp/目录/文件7.mkdown']
        for f in invalid_files:
            assert not utils.check_extension(f)

    def test_copytree_common(self):
        utils.copytree(self.content, self.output)
        assert os.path.exists(self.output) and os.path.isdir(self.output)

        files = [
            os.path.join('python', 'zen_of_python.md'),
            os.path.join('python', 'python文档.md'),
            os.path.join('其它', 'helloworld.markdown'),

            os.path.join('其它', '维基.md'),