Esempio n. 1
0
    def test_update_builtin_not_exists_with_no(self, mock_input):
        self.assertFalse(os.path.exists(self.local_fabfile))
        self.assertFalse(os.path.exists(self.local_theme))

        updater.update_builtin(**self.kwargs)

        self.assertFalse(os.path.exists(self.local_fabfile))
        self.assertFalse(os.path.exists(self.local_theme))
Esempio n. 2
0
    def test_update_builtin_not_exists_with_no(self, mock_input):
        self.assertFalse(os.path.exists(self.local_fabfile))
        self.assertFalse(os.path.exists(self.local_theme))

        updater.update_builtin(**self.kwargs)

        self.assertFalse(os.path.exists(self.local_fabfile))
        self.assertFalse(os.path.exists(self.local_theme))
Esempio n. 3
0
    def test_update_builtin_up_to_date(self):
        shutil.copyfile(self.original_fabfile, self.local_fabfile)
        utils.copytree(self.original_theme, self.local_theme)

        updater.update_builtin(**self.kwargs)

        original_fn_md5 = utils.get_md5(self.original_fabfile)
        local_fn_md5 = utils.get_md5(self.local_fabfile)
        self.assertEqual(original_fn_md5, local_fn_md5)

        original_fn_md5 = utils.get_dir_md5(self.original_theme)
        local_fn_md5 = utils.get_dir_md5(self.local_theme)
        self.assertEqual(original_fn_md5, local_fn_md5)
Esempio n. 4
0
    def test_update_builtin_up_to_date(self):
        shutil.copyfile(self.original_fabfile, self.local_fabfile)
        utils.copytree(self.original_theme, self.local_theme)

        updater.update_builtin(**self.kwargs)

        original_fn_md5 = utils.get_md5(self.original_fabfile)
        local_fn_md5 = utils.get_md5(self.local_fabfile)
        self.assertEqual(original_fn_md5, local_fn_md5)

        original_fn_md5 = utils.get_dir_md5(self.original_theme)
        local_fn_md5 = utils.get_dir_md5(self.local_theme)
        self.assertEqual(original_fn_md5, local_fn_md5)
Esempio n. 5
0
    def test_update_builtin_not_exists_with_yes(self, mock_input):
        self.assertFalse(os.path.exists(self.local_fabfile))
        self.assertFalse(os.path.exists(self.local_theme))

        updater.update_builtin(**self.kwargs)

        original_fn_md5 = utils.get_md5(self.original_fabfile)
        local_fn_md5 = utils.get_md5(self.local_fabfile)
        self.assertEqual(original_fn_md5, local_fn_md5)

        original_fn_md5 = utils.get_dir_md5(self.original_theme)
        local_fn_md5 = utils.get_dir_md5(self.local_theme)
        self.assertEqual(original_fn_md5, local_fn_md5)

        os.remove(self.local_theme_afile)
        updater.update_builtin(**self.kwargs)

        original_fn_md5 = utils.get_dir_md5(self.original_theme)
        local_fn_md5 = utils.get_dir_md5(self.local_theme)
        self.assertEqual(original_fn_md5, local_fn_md5)
Esempio n. 6
0
    def test_update_builtin_not_exists_with_yes(self, mock_input):
        self.assertFalse(os.path.exists(self.local_fabfile))
        self.assertFalse(os.path.exists(self.local_theme))

        updater.update_builtin(**self.kwargs)

        original_fn_md5 = utils.get_md5(self.original_fabfile)
        local_fn_md5 = utils.get_md5(self.local_fabfile)
        self.assertEqual(original_fn_md5, local_fn_md5)

        original_fn_md5 = utils.get_dir_md5(self.original_theme)
        local_fn_md5 = utils.get_dir_md5(self.local_theme)
        self.assertEqual(original_fn_md5, local_fn_md5)

        os.remove(self.local_theme_afile)
        updater.update_builtin(**self.kwargs)

        original_fn_md5 = utils.get_dir_md5(self.original_theme)
        local_fn_md5 = utils.get_dir_md5(self.local_theme)
        self.assertEqual(original_fn_md5, local_fn_md5)
Esempio n. 7
0
def main(args=None):
    global config

    if not args:
        args = docopt(__doc__, version="Simiki {0}".format(__version__))
    unicode_docopt(args)

    logging_init(logging.DEBUG)

    target_path = args['-p'] if args['-p'] else getcwdu()

    if args["init"]:
        init_site(target_path)
    else:
        config_file = os.path.join(target_path, "_config.yml")
        try:
            config = parse_config(config_file)
        except (Exception, YAMLError):
            # always in debug mode when parse config
            logging.exception("Parse config with error:")
            sys.exit(1)
        level = logging.DEBUG if config["debug"] else logging.INFO
        logging_init(level)   # reload logger

        if args["generate"] or args["g"]:
            generator = Generator(target_path)
            generator.generate(include_draft=args['--draft'])
        elif args["new"] or args["n"]:
            create_new_wiki(args["-c"], args["-t"], args["-f"])
        elif args["preview"] or args["p"]:
            args['--port'] = int(args['--port'])
            preview_site(args['--host'], args['--port'], config['destination'],
                         config['root'], args['-w'])
        elif args["update"]:
            update_builtin(themes_dir=config['themes_dir'])
        else:
            # docopt itself will display the help info.
            pass

    logger.info("Done.")
Esempio n. 8
0
def main(args=None):
    global config

    if not args:
        args = docopt(__doc__, version="Simiki {0}".format(__version__))
    unicode_docopt(args)

    logging_init(logging.DEBUG)

    target_path = args['-p'] if args['-p'] else getcwdu()

    if args["init"]:
        init_site(target_path)
    else:
        config_file = os.path.join(target_path, "_config.yml")
        try:
            config = parse_config(config_file)
        except (Exception, YAMLError):
            # always in debug mode when parse config
            logging.exception("Parse config with error:")
            sys.exit(1)
        level = logging.DEBUG if config["debug"] else logging.INFO
        logging_init(level)  # reload logger

        if args["generate"] or args["g"]:
            generator = Generator(target_path)
            generator.generate(include_draft=args['--draft'])
        elif args["new"] or args["n"]:
            create_new_wiki(args["-c"], args["-t"], args["-f"])
        elif args["preview"] or args["p"]:
            args['--port'] = int(args['--port'])
            preview_site(args['--host'], args['--port'], config['destination'],
                         config['root'], args['-w'])
        elif args["update"]:
            update_builtin(themes_dir=config['themes_dir'])
        else:
            # docopt itself will display the help info.
            pass

    logger.info("Done.")
Esempio n. 9
0
    def test_update_builtin_exists_with_no(self, mock_input):
        # empty fabfile.py
        with open(self.local_fabfile, 'wb') as _fd:
            _fd.close()
        original_fn_md5 = utils.get_md5(self.original_fabfile)
        local_fn_md5 = utils.get_md5(self.local_fabfile)
        self.assertNotEqual(original_fn_md5, local_fn_md5)

        utils.copytree(self.original_theme, self.local_theme)
        with open(self.local_theme_afile, 'wb') as _fd:
            _fd.close()
        original_fn_md5 = utils.get_dir_md5(self.original_theme)
        local_fn_md5 = utils.get_dir_md5(self.local_theme)
        self.assertNotEqual(original_fn_md5, local_fn_md5)

        updater.update_builtin(**self.kwargs)

        original_fn_md5 = utils.get_md5(self.original_fabfile)
        local_fn_md5 = utils.get_md5(self.local_fabfile)
        self.assertNotEqual(original_fn_md5, local_fn_md5)

        original_fn_md5 = utils.get_dir_md5(self.original_theme)
        local_fn_md5 = utils.get_dir_md5(self.local_theme)
        self.assertNotEqual(original_fn_md5, local_fn_md5)
Esempio n. 10
0
    def test_update_builtin_exists_with_no(self, mock_input):
        # empty fabfile.py
        with open(self.local_fabfile, 'wb') as _fd:
            _fd.close()
        original_fn_md5 = utils.get_md5(self.original_fabfile)
        local_fn_md5 = utils.get_md5(self.local_fabfile)
        self.assertNotEqual(original_fn_md5, local_fn_md5)

        utils.copytree(self.original_theme, self.local_theme)
        with open(self.local_theme_afile, 'wb') as _fd:
            _fd.close()
        original_fn_md5 = utils.get_dir_md5(self.original_theme)
        local_fn_md5 = utils.get_dir_md5(self.local_theme)
        self.assertNotEqual(original_fn_md5, local_fn_md5)

        updater.update_builtin(**self.kwargs)

        original_fn_md5 = utils.get_md5(self.original_fabfile)
        local_fn_md5 = utils.get_md5(self.local_fabfile)
        self.assertNotEqual(original_fn_md5, local_fn_md5)

        original_fn_md5 = utils.get_dir_md5(self.original_theme)
        local_fn_md5 = utils.get_dir_md5(self.local_theme)
        self.assertNotEqual(original_fn_md5, local_fn_md5)