Example #1
0
    def test_dump(self):
        Model.process = lambda _: 0

        self.config.parseOptions(['model', '--dump', 'test_model', 'test'])
        model = Model(self.config)
        model._dump_model()
        self.assertEqual(
            self.capture.getvalue(),
            '\n\n'
            '# -*- encoding: utf-8 -*-\n'
            '# -*- mamba-file-type: mamba-model -*-\n'
            '# Copyright (c) {year} - {author} <{author}@localhost>\n\n'
            '"""'
            '\n'
            '.. model:: TestModel\n'
            '    :plarform: Linux\n'
            '    :synopsis: None\n\n'
            '.. modelauthor:: {author} <{author}@localhost>\n'
            '"""\n\n'
            'from storm.locals import *\n\n'
            'from mamba.application import model\n\n\n'
            'class TestModel(model.Model):\n'
            '    """\n'
            '    None\n'
            '    """\n\n'
            '    __storm_table__ = \'test\'\n\n'
            '    id = Int(primary=True, unsigned=True)\n\n\n'.format(
                author=getpass.getuser(), year=datetime.datetime.now().year
            )
        )
Example #2
0
    def test_dump(self):
        Model.process = lambda _: 0

        self.config.parseOptions(['model', '--dump', 'test_model', 'test'])
        model = Model(self.config)
        model._dump_model()
        self.assertEqual(
            self.capture.getvalue(),
            '\n\n'
            '# -*- encoding: utf-8 -*-\n'
            '# -*- mamba-file-type: mamba-model -*-\n'
            '# Copyright (c) {year} - {author} <{author}@localhost>\n\n"""\n'
            '.. model:: TestModel\n'
            '    :plarform: Linux\n'
            '    :synopsis: None\n\n'
            '.. modelauthor:: {author} <{author}@localhost>\n'
            '"""\n\n'
            '# it\'s better if you remove this star import and import just '
            'what you\n# really need from mamba.enterprise\n'
            'from mamba.enterprise import *\n\n'
            'from mamba.application import model\n\n\n'
            'class TestModel(model.Model):\n    '
            '"""\n    None\n    """\n\n    __storm_table__ = \'test\'\n    \n'
            '    id = Int(primary=True, unsigned=True)\n\n\n'.format(
                author=getpass.getuser(), year=datetime.datetime.now().year
            )
        )