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')
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')
def test_warning_no_config_file(self, mock_readfp): mock_readfp.side_effect = IOError c = ConfigurationFile() c.read() self.mocked_facio_config_ConfigurationFile_warning.assert_any_call( "{0} Not found".format(self.config_path))
def test_config_read_success(self): config = dedent("""\ [template] template1 = /foo/bar/baz template2 = /baz/bar/foo """) patch_open = self._patch_open(config) patch_open.start() c = ConfigurationFile() c.read() self.mocked_facio_config_ConfigurationFile_out.assert_any_call( "Loaded {0}".format(self.config_path))
def test_config_read_parse_error(self, exit_mock): config = dedent("""\ [this_is not = formatted correctly """) patch_open = self._patch_open(config) patch_open.start() with self.assertRaises(FacioException): c = ConfigurationFile() c.read() self.mocked_facio_exceptions_puts.assert_any_call( "Error: Unable to parse {0}".format(self.config_path)) self.assertTrue(exit_mock.called)