def testGetFormatterInitCreate(self):
     """test the render for creating a new formatter init file"""
     mapper = formatter_init_mapping.FormatterInitMapping(
         fake_mapping_helper.FakeMappingHelper("template path"))
     data = init_data_model.InitDataModel(self.plugin_name, True)
     actual = mapper.GetRenderedTemplate(data)
     expected = "fake string formatter_init_template.jinja2"
     self.assertEqual(expected, actual)
 def testGetParserInitEdit(self):
     """test the render for editing a existing parser init file"""
     mapper = parser_init_mapping.ParserInitMapping(
         fake_mapping_helper.FakeMappingHelper("template path"))
     data = init_data_model.InitDataModel(self.plugin_name, False)
     actual = mapper.GetRenderedTemplate(data)
     expected = "fake string parser_init_template.jinja2"
     self.assertEqual(expected, actual)
    def testGenerateSQLitePluginWithExistingInit(self):
        """test the output of a generation of a sqlite plugin"""
        fake_handler = fake_file_handler.FakeFileHandler()
        mapping_helper = fake_mapping_helper.FakeMappingHelper(
            self.template_path)
        init_formatter_mapper = fake_sqliteplugin_mapping.FakeSQLitePluginMapper(
            mapping_helper)
        init_parser_mapper = fake_sqliteplugin_mapping.FakeSQLitePluginMapper(
            mapping_helper)
        parser_mapper = fake_sqliteplugin_mapping.FakeSQLitePluginMapper(
            mapping_helper)
        formatter_mapper = fake_sqliteplugin_mapping.FakeSQLitePluginMapper(
            mapping_helper)
        parser_test_mapper = fake_sqliteplugin_mapping.FakeSQLitePluginMapper(
            mapping_helper)
        formatter_test_mapper = (
            fake_sqliteplugin_mapping.FakeSQLitePluginMapper(mapping_helper))
        fake_database_information = (
            fake_sqlite_database_information.FakeSQLiteDatabaseInformation([]))

        with tempfile.TemporaryDirectory() as tmpdir:
            fake_path_helper = (
                fake_sqlite_plugin_path_helper.FakeSQLitePluginPathHelper(
                    self.template_path, 'test', 'db'))
            path = os.path.join(tmpdir, 'testfile')

            generator = sqlite_generator.SQLiteGenerator(
                tmpdir, 'test', 'test', [],
                output_handler_file.OutputHandlerFile(
                    path, file_handler.FileHandler()), self.plugin_helper,
                fake_path_helper)

            generator.init_formatter_exists = True
            generator.init_parser_exists = True

            generator.GenerateSQLitePlugin(
                tmpdir, fake_handler, init_formatter_mapper,
                init_parser_mapper, parser_mapper, formatter_mapper,
                parser_test_mapper, formatter_test_mapper, mapping_helper,
                fake_database_information)
            expected = (
                'create testcreate testcreate testcreate testcopy testedit '
                'testedit test')
            actual = self._ReadFromFile(path)
        self.assertEqual(expected, actual)