Beispiel #1
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')
Beispiel #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')
Beispiel #3
0
    def test_project_name_should_be_validated(self, mock_validate,
                                              mock_docopt):
        mock_docopt.return_value = {'<project_name>': 'foo'}

        i = CommandLineInterface()
        i.start()

        mock_validate.assert_called_with('foo')
Beispiel #4
0
    def test_valid_project_name(self):
        valid_names = ['this_is_valid', 'this1is_valid', 'Thisisvalid']

        i = CommandLineInterface()

        for name in valid_names:
            i.validate_project_name(name)
            self.assertEqual(name, self.mock_state.project_name)
            self.assertEqual({'PROJECT_NAME': name},
                             self.mock_state.context_variables)
Beispiel #5
0
    def test_project_name_should_be_validated(
            self,
            mock_validate,
            mock_docopt):
        mock_docopt.return_value = {
            '<project_name>': 'foo'
        }

        i = CommandLineInterface()
        i.start()

        mock_validate.assert_called_with('foo')
Beispiel #6
0
    def test_valid_project_name(self):
        valid_names = [
            'this_is_valid',
            'this1is_valid',
            'Thisisvalid']

        i = CommandLineInterface()

        for name in valid_names:
            i.validate_project_name(name)
            self.assertEqual(name, self.mock_state.project_name)
            self.assertEqual({'PROJECT_NAME': name},
                             self.mock_state.context_variables)
Beispiel #7
0
    def test_invalid_project_name(self, mock_exit):
        invalid_names = [
            'this_is_not-valid', 'this_is not_valid', '*this_is_not_valid'
        ]

        i = CommandLineInterface()

        for name in invalid_names:
            with self.assertRaises(FacioException):
                i.validate_project_name(name)
            self.mocked_facio_exceptions_puts.assert_any_call(
                'Error: Project names can only contain numbers letters and '
                'underscores')
Beispiel #8
0
    def test_invalid_project_name(self, mock_exit):
        invalid_names = [
            'this_is_not-valid',
            'this_is not_valid',
            '*this_is_not_valid']

        i = CommandLineInterface()

        for name in invalid_names:
            with self.assertRaises(FacioException):
                i.validate_project_name(name)
            self.mocked_facio_exceptions_puts.assert_any_call(
                'Error: Project names can only contain numbers letters and '
                'underscores')