Exemplo n.º 1
0
    def test_default(self):
        """
        The create_app with no arguments has to create a Holocron instance
        with default settings.
        """
        app = create_app()

        self.assertIsNotNone(app)
        self.assertIsInstance(app, Holocron)
Exemplo n.º 2
0
    def test_default(self):
        """
        The create_app with no arguments has to create a Holocron instance
        with default settings.
        """
        app = create_app()

        self.assertIsNotNone(app)
        self.assertIsInstance(app, Holocron)
Exemplo n.º 3
0
    def _create_app(self, conf_raw=None, side_effect=None):
        """
        Creates an application instance with mocked settings file. All
        arguments will be passed into mock_open.
        """
        mopen = mock.mock_open(read_data=conf_raw)
        mopen.side_effect = side_effect if side_effect else None

        with mock.patch('holocron.app.open', mopen, create=True):
            return create_app('_config.yml')
Exemplo n.º 4
0
    def _create_app(self, conf_raw=None, side_effect=None):
        """
        Creates an application instance with mocked settings file. All
        arguments will be passed into mock_open.
        """
        mopen = mock.mock_open(read_data=conf_raw)
        mopen.side_effect = side_effect if side_effect else None

        with mock.patch('holocron.app.open', mopen, create=True):
            return create_app('_config.yml')
Exemplo n.º 5
0
    def run(self):
        while not self._quit:

            if self._recreate_app:
                self._app = app.create_app(self._confpath) or self._app
                self._recreate_app = False

            if self._rebuild:
                self._app.run()
                self._rebuild = False

            time.sleep(self._sleep)
Exemplo n.º 6
0
    def run(self):
        while not self._quit:

            if self._recreate_app:
                self._app = app.create_app(self._confpath) or self._app
                self._recreate_app = False

            if self._rebuild:
                self._app.run()
                self._rebuild = False

            time.sleep(self._sleep)
Exemplo n.º 7
0
    def test_deprecation_user_theme_is_enabled_default_conf(self):
        """
        Tests that 'user-theme' extension is enabled by default, and
        deprecation warning is spawn.
        """
        warnings.simplefilter('always', DeprecationWarning)

        with warnings.catch_warnings(record=True) as w:
            app = create_app()

            self.assertEqual(DeprecationWarning, w[0].category)
            self.assertEqual(
                "'user-theme' isn't found in the list of enabled extensions. "
                "Since it'll be disabled by default in 0.4.0 release, please "
                "enable it explicitly if you still want to use it.",
                str(w[0].message))

        expected_ext = Holocron.default_conf['ext']['enabled'] + ['user-theme']
        self.assertCountEqual(expected_ext, app.conf['ext.enabled'])
Exemplo n.º 8
0
    def test_deprecation_user_theme_is_enabled_default_conf(self):
        """
        Tests that 'user-theme' extension is enabled by default, and
        deprecation warning is spawn.
        """
        warnings.simplefilter("always", DeprecationWarning)

        with warnings.catch_warnings(record=True) as w:
            app = create_app()

            self.assertEqual(DeprecationWarning, w[0].category)
            self.assertEqual(
                "'user-theme' isn't found in the list of enabled extensions. "
                "Since it'll be disabled by default in 0.4.0 release, please "
                "enable it explicitly if you still want to use it.",
                str(w[0].message),
            )

        expected_ext = Holocron.default_conf["ext"]["enabled"] + ["user-theme"]
        self.assertCountEqual(expected_ext, app.conf["ext.enabled"])
Exemplo n.º 9
0
def main(args=sys.argv[1:]):
    # get available commands and build cli based on it
    commands_manager = ExtensionManager('holocron.ext.commands')
    commands = {name: command() for name, command in commands_manager}
    arguments = parse_command_line(args, commands)

    # initial logger configuration - use custom format for records
    # and print records with WARNING level and higher.
    configure_logger(arguments.verbosity or logging.WARNING)

    # show deprecation warnings in order to be prepared for backward
    # incompatible changes
    warnings.filterwarnings('always', category=DeprecationWarning)

    # create app instance
    holocron = create_app(arguments.conf)
    if holocron is None:
        sys.exit(1)

    # execute passed command
    commands[arguments.command].execute(holocron, arguments)
Exemplo n.º 10
0
def main(args=sys.argv[1:]):
    # get available commands and build cli based on it
    commands_manager = ExtensionManager('holocron.ext.commands')
    commands = {name: command() for name, command in commands_manager}
    arguments = parse_command_line(args, commands)

    # initial logger configuration - use custom format for records
    # and print records with WARNING level and higher.
    configure_logger(arguments.verbosity or logging.WARNING)

    # show deprecation warnings in order to be prepared for backward
    # incompatible changes
    warnings.filterwarnings('always', category=DeprecationWarning)

    # create app instance
    holocron = create_app(arguments.conf)
    if holocron is None:
        sys.exit(1)

    # execute passed command
    commands[arguments.command].execute(holocron, arguments)