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

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
Esempio n. 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)
Esempio n. 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)
Esempio n. 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
Esempio n. 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
Esempio n. 14
0
    def test_nose(self):
        old = sys.argv
        sys.argv = ['nosetests']

        alchemist.configure(self.app)

        assert self.app.config['TESTING']

        sys.argv = old
Esempio n. 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)
Esempio n. 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)
Esempio n. 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']
Esempio n. 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
Esempio n. 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
Esempio n. 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']
Esempio n. 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
Esempio n. 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
Esempio n. 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'
Esempio n. 24
0
    def setup(self):
        self.app = Flask('alchemist')
        self.app.config['COMPONENTS'] = ['alchemist']

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

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

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

        alchemist.configure(self.app)
Esempio n. 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)
Esempio n. 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)