Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
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)
Beispiel #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)
Beispiel #5
0
    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
Beispiel #6
0
    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
Beispiel #7
0
    def test_alchemist(self):
        old = sys.argv
        sys.argv = ['alchemist', 'test']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
Beispiel #8
0
    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
Beispiel #9
0
    def test_nose(self):
        old = sys.argv
        sys.argv = ['nosetests']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
Beispiel #10
0
    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)
Beispiel #11
0
    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)
Beispiel #12
0
    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
Beispiel #13
0
    def test_alchemist(self):
        old = sys.argv
        sys.argv = ['alchemist', 'test']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
Beispiel #14
0
    def test_nose(self):
        old = sys.argv
        sys.argv = ['nosetests']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
Beispiel #15
0
    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)
Beispiel #16
0
    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)
Beispiel #17
0
    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']
Beispiel #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
    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
Beispiel #20
0
    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']
Beispiel #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
    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
Beispiel #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'
Beispiel #24
0
    def setup(self):
        self.app = Flask('alchemist')
        self.app.config['COMPONENTS'] = ['alchemist']

        alchemist.configure(self.app)
    def setup(self):
        self.app = Flask('alchemist')
        self.app.config['COMPONENTS'] = ['alchemist']

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

        alchemist.configure(self.app)
Beispiel #27
0
    def setup(self):
        self.app = Flask('alchemist.tests.a')
        self.context = self.app.app_context()
        self.context.push()

        alchemist.configure(self.app)
Beispiel #28
0
    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)
Beispiel #29
0
    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)