Example #1
0
    def test_list_templates(self):
        codegen = QEFortranGenerator(self.schema)
        templates = codegen.list_templates()

        self.assertIn('base.f90.jinja', templates)
        self.assertNotIn('qes_read_module.f90.jinja', templates)
        self.assertIn('read/qes_read_module.f90.jinja', templates)
        self.assertIn('types/qes_types_module.f90.jinja', templates)

        searchpath = Path(__file__).absolute().parent.joinpath(
            'templates/fortran/')
        self.assertTrue(searchpath.is_dir())
        codegen = QEFortranGenerator(self.schema, str(searchpath))

        templates = codegen.list_templates()
        self.assertIn('base.f90.jinja', templates)
        self.assertIn('qes_types_module.f90.jinja', templates)
        self.assertIn('types/qes_types_module.f90.jinja', templates)
Example #2
0
    def test_get_template(self):
        codegen = QEFortranGenerator(self.schema)
        template = codegen.get_template('base.f90.jinja')
        with open(template.filename) as fp:
            self.assertNotIn("{# Override base90.f90 template #}", fp.read())

        template = codegen.get_template('read/qes_read_module.f90.jinja')
        with open(template.filename) as fp:
            self.assertIn("MODULE qes_read_module", fp.read())

        searchpath = Path(__file__).absolute().parent.joinpath(
            'templates/fortran/')
        self.assertTrue(searchpath.is_dir())

        codegen = QEFortranGenerator(self.schema, str(searchpath))
        template = codegen.get_template('base.f90.jinja')
        with open(template.filename) as fp:
            self.assertIn("{# Override base90.f90 template #}", fp.read())
Example #3
0
 def test_initialization(self):
     codegen = QEFortranGenerator(str(self.xsd_file))
     self.assertIsInstance(codegen.schema, xmlschema.XMLSchema)
     self.assertIsInstance(codegen._env, jinja2.Environment)
Example #4
0
 def test_render_init_module(self):
     qe_generator = QEFortranGenerator(self.schema)
     result = qe_generator.render('init/qes_init_module.f90.jinja')[0]
     self.assertIsInstance(result, str)
     self.check_module('samples/qe/qes_init_module.f90', result)