Exemple #1
0
    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()
Exemple #2
0
    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()
Exemple #3
0
    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
Exemple #4
0
    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()
Exemple #5
0
    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()
Exemple #6
0
    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() == []
Exemple #7
0
    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
Exemple #8
0
    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() == []
Exemple #9
0
    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
Exemple #10
0
    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
Exemple #11
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)
Exemple #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)
Exemple #13
0
    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()
Exemple #14
0
    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()
Exemple #15
0
    def teardown(self):
        from alchemist import db

        db.clear()

        self.context.pop()
Exemple #16
0
    def teardown(self):
        from alchemist import db

        db.clear()

        self.context.pop()
Exemple #17
0
 def finalizer():
     db.session.rollback()
     db.clear(database=True)
Exemple #18
0
 def run(self, *args, **kwargs):
     db.clear(*args, **kwargs)
Exemple #19
0
 def run(self, *args, **kwargs):
     db.clear(*args, **kwargs)
Exemple #20
0
 def finalizer():
     db.session.rollback()
     db.clear(database=True)