コード例 #1
0
    def test_write_file(self):
        Controller.process = lambda _: 0

        with fake_project():
            self.config.parseOptions(['controller', 'test_controller'])
            controller = Controller(self.config)
            controller._write_controller()
            controller_file = filepath.FilePath(
                'application/controller/test_controller.py')

            self.assertTrue(controller_file.exists())
            controller_file.remove()
コード例 #2
0
    def test_write_file(self):
        Controller.process = lambda _: 0

        with fake_project():
            self.config.parseOptions(['controller', 'test_controller'])
            controller = Controller(self.config)
            controller._write_controller()
            controller_file = filepath.FilePath(
                'application/controller/test_controller.py'
            )

            self.assertTrue(controller_file.exists())
            controller_file.remove()
コード例 #3
0
    def test_write_file(self):
        Controller.process = lambda _: 0

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

        self.config.parseOptions(['controller', 'test_controller'])
        controller = Controller(self.config)
        controller._write_controller()
        controller_file = filepath.FilePath(
            'application/controller/test_controller.py')

        self.assertTrue(controller_file.exists())
        controller_file.remove()

        os.chdir(currdir)
コード例 #4
0
ファイル: test_mamba_admin.py プロジェクト: cypreess/mamba
    def test_write_file(self):
        Controller.process = lambda _: 0

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

        self.config.parseOptions(['controller', 'test_controller'])
        controller = Controller(self.config)
        controller._write_controller()
        controller_file = filepath.FilePath(
            'application/controller/test_controller.py'
        )

        self.assertTrue(controller_file.exists())
        controller_file.remove()

        os.chdir(currdir)
コード例 #5
0
ファイル: test_mamba_admin.py プロジェクト: cypreess/mamba
    def test_dump(self):
        Controller.process = lambda _: 0

        self.config.parseOptions(['controller', '--dump', 'test_controller'])
        controller = Controller(self.config)
        controller._dump_controller()
        self.assertEqual(
            self.capture.getvalue(),
            '\n\n'
            '# -*- encoding: utf-8 -*-\n'
            '# -*- mamba-file-type: mamba-controller -*-\n'
            '# Copyright (c) {year} - {author} <{author}@localhost>\n\n'
            '"""\n'
            '.. controller:: TestController\n'
            '    :platform: Linux\n'
            '    :synopsis: None\n\n'
            '.. controllerauthor:: {author} <{author}@localhost>\n'
            '"""\n\n'
            'from zope.interface import implements\n\n'
            'from mamba.web.response import Ok\n'
            'from mamba.core import interfaces\n'
            'from mamba.application import route\n'
            'from mamba.application import controller\n\n\n'
            'class TestController(controller.Controller):\n'
            '    """\n'
            '    None\n'
            '    """\n\n'
            '    implements(interfaces.IController)\n'
            '    name = \'TestController\'\n'
            '    loaded = False\n'
            '    __route__ = \'\'\n\n'
            '    def __init__(self):\n'
            '        """\n'
            '        Put your initializarion code here\n'
            '        """\n'
            '        super(TestController, self).__init__()\n\n'
            '    @route(\'/\')\n'
            '    def root(self, request, **kwargs):\n'
            '        return Ok(\'I am the TestController, hello world!\')'
            '\n\n'.format(
                year=datetime.datetime.now().year, author=getpass.getuser())
        )
コード例 #6
0
    def test_dump(self):
        Controller.process = lambda _: 0

        self.config.parseOptions(['controller', '--dump', 'test_controller'])
        controller = Controller(self.config)
        controller._dump_controller()
        self.assertEqual(
            self.capture.getvalue(),
            '\n\n'
            '# -*- encoding: utf-8 -*-\n'
            '# -*- mamba-file-type: mamba-controller -*-\n'
            '# Copyright (c) {year} - {author} <{author}@localhost>\n\n'
            '"""\n'
            '.. controller:: TestController\n'
            '    :platform: Linux\n'
            '    :synopsis: None\n\n'
            '.. controllerauthor:: {author} <{author}@localhost>\n'
            '"""\n\n'
            'from zope.interface import implements\n\n'
            'from mamba.web.response import Ok\n'
            'from mamba.core import interfaces\n'
            'from mamba.application import route\n'
            'from mamba.application import controller\n\n\n'
            'class TestController(controller.Controller):\n'
            '    """\n'
            '    None\n'
            '    """\n\n'
            '    implements(interfaces.IController)\n'
            '    name = \'TestController\'\n'
            '    loaded = False\n'
            '    __route__ = \'\'\n\n'
            '    def __init__(self):\n'
            '        """\n'
            '        Put your initializarion code here\n'
            '        """\n'
            '        super(TestController, self).__init__()\n\n'
            '    @route(\'/\')\n'
            '    def root(self, request, **kwargs):\n'
            '        return Ok(\'I am the TestController, hello world!\')'
            '\n\n'.format(
                year=datetime.datetime.now().year, author=getpass.getuser())
        )