コード例 #1
0
ファイル: run.py プロジェクト: jackqu7/Facio
    def run(self):
        """ Run the Facio processes. """

        interface = CommandLineInterface()
        interface.start()

        config = ConfigurationFile()
        parsed = config.read()

        settings = Settings(interface, parsed)
        state.update_context_variables(settings.get_variables())

        template = Template(settings.get_template_path())
        template.update_copy_ignore_globs(settings.copy_ignore_globs())
        template.update_render_ignore_globs(settings.render_ignore_globs())
        template.copy()

        pipeline = Hook()
        pipeline.load(os.path.join(
            state.get_project_root(),
            HOOKS_FILE_NAME))

        if pipeline.has_before():
            pipeline.run_before()

        template.rename()
        template.render()

        if pipeline.has_after():
            pipeline.run_after()

        self.success('Done')
コード例 #2
0
    def run(self):
        """ Run the Facio processes. """

        interface = CommandLineInterface()
        interface.start()

        config = ConfigurationFile()
        parsed = config.read()

        settings = Settings(interface, parsed)
        state.update_context_variables(settings.get_variables())

        template = Template(settings.get_template_path())
        template.update_copy_ignore_globs(settings.copy_ignore_globs())
        template.update_render_ignore_globs(settings.render_ignore_globs())
        template.copy()

        pipeline = Hook()
        pipeline.load(os.path.join(state.get_project_root(), HOOKS_FILE_NAME))

        if pipeline.has_before():
            pipeline.run_before()

        template.rename()
        template.render()

        if pipeline.has_after():
            pipeline.run_after()

        self.success('Done')
コード例 #3
0
ファイル: test_template.py プロジェクト: jackqu7/Facio
    def test_copy_oserror_vcs_path_recursion_limit(
            self,
            mock_copy_tree,
            mock_isdir,
            mock_gitvcs,
            mock_exit):

        instance = Template('git+/foo/bar')
        with self.assertRaises(FacioException):
            instance.copy()
        self.assertTrue(mock_exit.called)
        self.mocked_facio_exceptions_puts.assert_any_call(
            'Error: Failed to copy template after 6 attempts')
コード例 #4
0
ファイル: test_template.py プロジェクト: jackqu7/Facio
    def test_copy_oserror_vcs_path(
            self,
            mock_copy_tree,
            mock_isdir,
            mock_gitvcs,
            mock_exit):

        instance = Template('git+/foo/bar')
        instance.COPY_ATTEMPT_LIMIT = 0  # Block the next copy call

        with self.assertRaises(FacioException):
            instance.copy()
        mock_gitvcs.assert_called_with('git+/foo/bar')
コード例 #5
0
ファイル: test_template.py プロジェクト: jackqu7/Facio
    def test_copy_shutil_error_raise_exception(
            self,
            mock_copy_tree,
            mock_pwd,
            mock_exit):

        instance = Template('/foo/bar')

        with self.assertRaises(FacioException):
            instance.copy()
        self.assertTrue(mock_exit.called)
        self.mocked_facio_exceptions_puts.assert_any_call(
            'Error: Failed to copy /foo/bar to /tmp/foo')
コード例 #6
0
ファイル: test_template.py プロジェクト: jackqu7/Facio
    def test_copy_oserror_vcs_clone_returns_not_path(
            self,
            mock_copy_tree,
            mock_isdir,
            mock_gitvcs,
            mock_exit):

        instance = Template('git+/foo/bar')
        instance.COPY_ATTEMPT_LIMIT = 0  # Block the next copy call

        with self.assertRaises(FacioException):
            instance.copy()
        self.mocked_facio_exceptions_puts.assert_any_call(
            'Error: New path to template not returned by GitVCS.clone()')
コード例 #7
0
ファイル: test_template.py プロジェクト: jackqu7/Facio
    def test_copy_oserror_not_vcs_path_exception(
            self,
            mock_copy_tree,
            mock_isdir,
            mock_pwd,
            mock_exit):

        instance = Template('/foo/bar')

        with self.assertRaises(FacioException):
            instance.copy()
        mock_isdir.assert_called_with('/tmp/foo')
        self.assertTrue(mock_exit.called)
        self.mocked_facio_exceptions_puts.assert_any_call(
            'Error: /foo/bar does not exist')
コード例 #8
0
ファイル: test_template.py プロジェクト: jackqu7/Facio
    def test_copy_shutil_oserror_raise_exception(
            self,
            mock_copy_tree,
            mock_isdir,
            mock_pwd,
            mock_exit):

        instance = Template('/foo/bar')

        with self.assertRaises(FacioException):
            instance.copy()
        mock_isdir.assert_called_with('/tmp/foo')
        self.assertTrue(mock_exit.called)
        self.mocked_facio_exceptions_puts.assert_any_call(
            'Error: /tmp/foo already exists')
コード例 #9
0
ファイル: test_template.py プロジェクト: jackqu7/Facio
    def test_copy_callback_call(self, mock_copy_tree, mock_pwd):
        from facio.state import state
        instance = Template('/foo/bar')
        callback = MagicMock()

        self.assertTrue(instance.copy(callback=callback))
        callback.assert_called_once_with(
            origin=instance.origin,
            destination=state.get_project_root())
コード例 #10
0
ファイル: test_template.py プロジェクト: jackqu7/Facio
    def test_copy_returns_true(self, mock_copy_tree):
        instance = Template('/foo/bar')

        self.assertTrue(instance.copy())