Пример #1
0
    def setup(self):
        from alchemist import db

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

        db.init()
Пример #2
0
    def setup(self):
        from alchemist import db

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

        db.init()
Пример #3
0
    def test_init_short_name(self):
        from alchemist import db
        from .a.models import Entity

        with raises(OperationalError):
            assert Entity.query.all()

        db.init(names=['alchemist.tests.a:Entity'])

        assert Entity.query.all() == []
Пример #4
0
    def test_init(self):
        from alchemist import db
        from .a.models import Entity

        with raises(OperationalError):
            assert Entity.query.all()

        db.init()

        assert Entity.query.all() == []
Пример #5
0
    def test_init(self):
        from alchemist import db
        from .a.models import Entity

        with raises(OperationalError):
            assert Entity.query.all()

        db.init()

        assert Entity.query.all() == []
Пример #6
0
    def test_init_short_name(self):
        from alchemist import db
        from .a.models import Entity

        with raises(OperationalError):
            assert Entity.query.all()

        db.init(names=['alchemist.tests.a:Entity'])

        assert Entity.query.all() == []
Пример #7
0
    def test_init_echo(self):
        from alchemist import db

        capture = py.io.StdCapture(out=True, in_=False)
        db.init(echo=True)
        out, err = capture.done()

        text = out.read()

        assert 'CREATE TABLE' in text
        assert 'alchemist_tests_a_entity' in text
Пример #8
0
    def test_init_verbose(self):
        from alchemist import db

        capture = py.io.StdCapture(out=True, in_=False)
        db.init(verbose=True)
        out, err = capture.done()

        text = err.read()

        assert 'create' in text
        assert 'alchemist_tests_a_entity' in text
Пример #9
0
    def test_init_echo(self):
        from alchemist import db

        capture = py.io.StdCapture(out=True, in_=False)
        db.init(echo=True)
        out, err = capture.done()

        text = out.read()

        assert 'CREATE TABLE' in text
        assert 'alchemist_tests_a_entity' in text
Пример #10
0
    def test_init_verbose(self):
        from alchemist import db

        capture = py.io.StdCapture(out=True, in_=False)
        db.init(verbose=True)
        out, err = capture.done()

        text = err.read()

        assert 'create' in text
        assert 'alchemist_tests_a_entity' in text
Пример #11
0
    def test_init_offline(self):
        from alchemist import db
        from .a.models import Entity

        with raises(OperationalError):
            assert Entity.query.all()

        capture = py.io.StdCapture(out=True, in_=False)
        db.init(offline=True)
        _, _ = capture.done()

        with raises(OperationalError):
            assert Entity.query.all()
Пример #12
0
def fixture_database(request):
    # Clear out old database contents.
    db.clear(database=True)

    # Initialize the database access layer.
    db.init(database=True)

    # Ensure we clear out the database at the end.
    def finalizer():
        db.session.rollback()
        db.clear(database=True)

    request.addfinalizer(finalizer)
Пример #13
0
    def setup(self):
        from alchemist import db

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

        db.init()

        from .a.models import Entity

        db.session.add(Entity())
        db.session.commit()
Пример #14
0
    def test_init_offline(self):
        from alchemist import db
        from .a.models import Entity

        with raises(OperationalError):
            assert Entity.query.all()

        capture = py.io.StdCapture(out=True, in_=False)
        db.init(offline=True)
        _, _ = capture.done()

        with raises(OperationalError):
            assert Entity.query.all()
Пример #15
0
    def setup(self):
        from alchemist import db

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

        db.init()

        from .a.models import Entity

        db.session.add(Entity())
        db.session.commit()
Пример #16
0
def fixture_database(request):
    # Clear out old database contents.
    db.clear(database=True)

    # Initialize the database access layer.
    db.init(database=True)

    # Ensure we clear out the database at the end.
    def finalizer():
        db.session.rollback()
        db.clear(database=True)

    request.addfinalizer(finalizer)
Пример #17
0
 def run(self, *args, **kwargs):
     db.init(*args, **kwargs)
Пример #18
0
 def run(self, *args, **kwargs):
     db.init(*args, **kwargs)