Esempio n. 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
            )
        )
Esempio n. 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
            )
        )
Esempio n. 3
0
    def test_write_file(self):
        Model.process = lambda _: 0

        with fake_project():
            self.config.parseOptions(['model', 'test_model', 'test'])
            model = Model(self.config)
            model._write_model()
            model_file = filepath.FilePath('application/model/test_model.py')

            self.assertTrue(model_file.exists())
            model_file.remove()
Esempio n. 4
0
    def test_write_file(self):
        Model.process = lambda _: 0

        with fake_project():
            self.config.parseOptions(['model', 'test_model', 'test'])
            model = Model(self.config)
            model._write_model()
            model_file = filepath.FilePath(
                'application/model/test_model.py'
            )

            self.assertTrue(model_file.exists())
            model_file.remove()
Esempio n. 5
0
    def test_write_file(self):
        Model.process = lambda _: 0

        currdir = os.getcwd()
        os.chdir('../mamba/test/dummy_app/')

        self.config.parseOptions(['model', 'test_model', 'test'])
        model = Model(self.config)
        model._write_model()
        model_file = filepath.FilePath('application/model/test_model.py')

        self.assertTrue(model_file.exists())
        model_file.remove()

        os.chdir(currdir)
Esempio n. 6
0
    def test_write_file(self):
        Model.process = lambda _: 0

        currdir = os.getcwd()
        os.chdir('../mamba/test/dummy_app/')

        self.config.parseOptions(['model', 'test_model', 'test'])
        model = Model(self.config)
        model._write_model()
        model_file = filepath.FilePath(
            'application/model/test_model.py'
        )

        self.assertTrue(model_file.exists())
        model_file.remove()

        os.chdir(currdir)