def setup(self): from alchemist import db self.app = Flask('alchemist.tests.a') self.context = self.app.app_context() self.context.push() db.init()
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() == []
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() == []
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
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
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()
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)
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()
def run(self, *args, **kwargs): db.init(*args, **kwargs)