コード例 #1
0
ファイル: test_app.py プロジェクト: concordusapps/alchemist
    def test_component(self):
        self.app = Flask('alchemist.tests.a')
        with settings(self.app, COMPONENTS=['alchemist.tests.a.b']):
            alchemist.configure(self.app)

            assert self.app.config.get('B_SETTING', 1)
            assert self.app.config.get('A_SETTING', 5)
コード例 #2
0
ファイル: test_app.py プロジェクト: shuyunqi/alchemist
    def test_component(self):
        self.app = Flask('alchemist.tests.a')
        with settings(self.app, COMPONENTS=['alchemist.tests.a.b']):
            alchemist.configure(self.app)

            assert self.app.config.get('B_SETTING', 1)
            assert self.app.config.get('A_SETTING', 5)
コード例 #3
0
ファイル: test_db.py プロジェクト: concordusapps/alchemist
    def setup(self):
        utils.unload_modules('alchemist')

        self.app = Flask('alchemist.tests.a')
        self.context = self.app.app_context()
        self.context.push()

        alchemist.configure(self.app)
コード例 #4
0
    def setup(self):
        utils.unload_modules('alchemist')

        self.app = Flask('alchemist.tests.a')
        self.context = self.app.app_context()
        self.context.push()

        alchemist.configure(self.app)
コード例 #5
0
ファイル: test_app.py プロジェクト: shuyunqi/alchemist
    def test_not(self):
        old = sys.argv
        sys.argv = ['alchemist', 'load', '../../test.py']

        alchemist.configure(self.app)

        assert not self.app.config['TESTING']

        sys.argv = old
コード例 #6
0
ファイル: test_app.py プロジェクト: concordusapps/alchemist
    def test_not(self):
        old = sys.argv
        sys.argv = ['alchemist', 'load', '../../test.py']

        alchemist.configure(self.app)

        assert not self.app.config['TESTING']

        sys.argv = old
コード例 #7
0
ファイル: test_app.py プロジェクト: concordusapps/alchemist
    def test_alchemist(self):
        old = sys.argv
        sys.argv = ['alchemist', 'test']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
コード例 #8
0
ファイル: test_app.py プロジェクト: concordusapps/alchemist
    def test_unittest(self):
        old = sys.argv
        sys.argv = ['python', 'setup.py', 'test']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
コード例 #9
0
ファイル: test_app.py プロジェクト: concordusapps/alchemist
    def test_nose(self):
        old = sys.argv
        sys.argv = ['nosetests']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
コード例 #10
0
ファイル: test_app.py プロジェクト: concordusapps/alchemist
    def test_missing_project(self):
        """
        Should succeed and not raise if the project does not contain
        a settings file.
        """

        self.app = Flask('alchemist')
        with settings(self.app):
            alchemist.configure(self.app)
コード例 #11
0
ファイル: test_app.py プロジェクト: shuyunqi/alchemist
    def test_missing_project(self):
        """
        Should succeed and not raise if the project does not contain
        a settings file.
        """

        self.app = Flask('alchemist')
        with settings(self.app):
            alchemist.configure(self.app)
コード例 #12
0
ファイル: test_app.py プロジェクト: shuyunqi/alchemist
    def test_unittest(self):
        old = sys.argv
        sys.argv = ['python', 'setup.py', 'test']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
コード例 #13
0
ファイル: test_app.py プロジェクト: shuyunqi/alchemist
    def test_alchemist(self):
        old = sys.argv
        sys.argv = ['alchemist', 'test']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
コード例 #14
0
ファイル: test_app.py プロジェクト: shuyunqi/alchemist
    def test_nose(self):
        old = sys.argv
        sys.argv = ['nosetests']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
コード例 #15
0
ファイル: test_app.py プロジェクト: shuyunqi/alchemist
    def test_project_as_component(self):
        """
        Should not merge the project settings in twice even if
        it is listed in the COMPONENTS array.
        """

        self.app = Flask('alchemist.tests.a')
        components = ['alchemist.tests.a.b', 'alchemist.tests.a']
        with settings(self.app, COMPONENTS=components):
            alchemist.configure(self.app)

            assert self.app.config.get('B_SETTING', 1)
            assert self.app.config.get('A_SETTING', 5)
コード例 #16
0
ファイル: test_app.py プロジェクト: concordusapps/alchemist
    def test_project_as_component(self):
        """
        Should not merge the project settings in twice even if
        it is listed in the COMPONENTS array.
        """

        self.app = Flask('alchemist.tests.a')
        components = ['alchemist.tests.a.b', 'alchemist.tests.a']
        with settings(self.app, COMPONENTS=components):
            alchemist.configure(self.app)

            assert self.app.config.get('B_SETTING', 1)
            assert self.app.config.get('A_SETTING', 5)
コード例 #17
0
ファイル: test_app.py プロジェクト: concordusapps/alchemist
    def test_project_env(self):
        """
        Should override settings from the file specified in the
        <project>_SETTINGS_MODULE environ variable.
        """

        filename = path.join(path.dirname(__file__), '../a/b/settings.py')
        os.environ['TESTS_A_SETTINGS_MODULE'] = filename

        self.app = Flask('alchemist.tests.a')
        with settings(self.app):
            alchemist.configure(self.app)

            assert self.app.config.get('B_SETTING', 1)
            assert self.app.config.get('A_SETTING', 5)

        del os.environ['TESTS_A_SETTINGS_MODULE']
コード例 #18
0
    def test_context(self):
        utils.unload_modules('alchemist')

        from alchemist.commands import Shell
        shell = Shell()

        self.app = Flask('alchemist.tests.a')
        self.context = self.app.app_context()
        with self.context:

            alchemist.configure(self.app)

            context = shell.make_context()

            assert 'db' in context
            assert 'session' in context
            assert 'Entity' in context
コード例 #19
0
    def test_context(self):
        utils.unload_modules('alchemist')

        from alchemist.commands import Shell
        shell = Shell()

        self.app = Flask('alchemist.tests.a')
        self.context = self.app.app_context()
        with self.context:

            alchemist.configure(self.app)

            context = shell.make_context()

            assert 'db' in context
            assert 'session' in context
            assert 'Entity' in context
コード例 #20
0
ファイル: test_app.py プロジェクト: shuyunqi/alchemist
    def test_project_env(self):
        """
        Should override settings from the file specified in the
        <project>_SETTINGS_MODULE environ variable.
        """

        filename = path.join(path.dirname(__file__), '../a/b/settings.py')
        os.environ['TESTS_A_SETTINGS_MODULE'] = filename

        self.app = Flask('alchemist.tests.a')
        with settings(self.app):
            alchemist.configure(self.app)

            assert self.app.config.get('B_SETTING', 1)
            assert self.app.config.get('A_SETTING', 5)

        del os.environ['TESTS_A_SETTINGS_MODULE']
コード例 #21
0
    def test_pipe(self):
        utils.unload_modules('alchemist')

        self.app = Flask('alchemist.tests.a')
        self.context = self.app.app_context()

        with self.context:
            alchemist.configure(self.app)

            stdin = sys.stdin
            sys.stdin = io.StringIO('print(Entity)\nprint(session)')

            capture = py.io.StdCapture(out=True, in_=False)
            self._run(['shell', '--pipe'])
            out, err = capture.done()

            text = ("<class 'alchemist.tests.a.models.Entity'>\n"
                    "<Session(bind=Engine(sqlite:///:memory:))>\n")

            assert text == out.read()

            sys.stdin = stdin
コード例 #22
0
    def test_pipe(self):
        utils.unload_modules('alchemist')

        self.app = Flask('alchemist.tests.a')
        self.context = self.app.app_context()

        with self.context:
            alchemist.configure(self.app)

            stdin = sys.stdin
            sys.stdin = io.StringIO('print(Entity)\nprint(session)')

            capture = py.io.StdCapture(out=True, in_=False)
            self._run(['shell', '--pipe'])
            out, err = capture.done()

            text = ("<class 'alchemist.tests.a.models.Entity'>\n"
                    "<Session(bind=Engine(sqlite:///:memory:))>\n")

            assert text == out.read()

            sys.stdin = stdin
コード例 #23
0
from flask import Flask
import alchemist
import alchemist_armet

application = Flask(__package__)

# Configure the application object.
alchemist.configure(application)
alchemist_armet.configure(application)

# @application.route('/')
# def index():
#     return 'text on the screen'
コード例 #24
0
    def setup(self):
        self.app = Flask('alchemist')
        self.app.config['COMPONENTS'] = ['alchemist']

        alchemist.configure(self.app)
コード例 #25
0
    def setup(self):
        self.app = Flask('alchemist')
        self.app.config['COMPONENTS'] = ['alchemist']

        alchemist.configure(self.app)
コード例 #26
0
    def setup(self):
        self.app = Flask('alchemist.tests.a')
        self.context = self.app.app_context()
        self.context.push()

        alchemist.configure(self.app)
コード例 #27
0
ファイル: test_db.py プロジェクト: concordusapps/alchemist
    def setup(self):
        self.app = Flask('alchemist.tests.a')
        self.context = self.app.app_context()
        self.context.push()

        alchemist.configure(self.app)
コード例 #28
0
ファイル: test_app.py プロジェクト: concordusapps/alchemist
    def test_project(self):
        self.app = Flask('alchemist.tests.a')
        with settings(self.app):
            alchemist.configure(self.app)

            assert self.app.config.get('A_SETTING', 1)
コード例 #29
0
ファイル: test_app.py プロジェクト: shuyunqi/alchemist
    def test_project(self):
        self.app = Flask('alchemist.tests.a')
        with settings(self.app):
            alchemist.configure(self.app)

            assert self.app.config.get('A_SETTING', 1)