def test_clear_name(self): from alchemist import db from .a.models import Entity assert Entity.query.all() == [] db.clear(names=['alchemist.tests.a']) with raises(OperationalError): assert Entity.query.all()
def test_clear_verbose(self): from alchemist import db capture = py.io.StdCapture(out=True, in_=False) db.clear(verbose=True) out, err = capture.done() text = err.read() assert 'drop' in text assert 'alchemist_tests_a_entity' in text
def test_flush_non_existing(self): from alchemist import db from .a.models import Entity assert len(Entity.query.all()) == 1 db.clear() db.flush() with raises(OperationalError): assert Entity.query.all()
def test_clear_offline(self): from alchemist import db from .a.models import Entity assert Entity.query.all() == [] capture = py.io.StdCapture(out=True, in_=False) db.clear(offline=True) _, _ = capture.done() assert Entity.query.all() == []
def test_clear_echo(self): from alchemist import db capture = py.io.StdCapture(out=True, in_=False) db.clear(echo=True) out, err = capture.done() text = out.read() assert 'DROP TABLE' in text assert 'alchemist_tests_a_entity' in text
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 test_clear_twice(self): from alchemist import db from .a.models import Entity assert Entity.query.all() == [] db.clear() with raises(OperationalError): assert Entity.query.all() db.clear() with raises(OperationalError): assert Entity.query.all()
def teardown(self): from alchemist import db db.clear() self.context.pop()
def finalizer(): db.session.rollback() db.clear(database=True)
def run(self, *args, **kwargs): db.clear(*args, **kwargs)