# Path: pushmanager/core/db.py
# def UnsignedInteger():
# def init_db():
# def finalize_db():
# def execute_cb(query, callback_fn):
# def execute_transaction_cb(queries, callback_fn, condition=None):
# def prefix_insert_ignore(insert_ignore, compiler, **kw):
# def prefix_insert_ignore_sqlite(insert_ignore, compiler, **kw):
# class DatabaseError(Exception):
# class PushCheckList(Base):
# class PushPlans(Base):
# class PushPushContents(Base):
# class PushPushes(Base):
# class PushRemovals(Base):
# class PushRequests(Base):
# class InsertIgnore(Insert):
# 
# Path: pushmanager/testing/mocksettings.py



import os
import sqlalchemy as SA
import mock
import testify as T
from sqlalchemy.schema import Column
from sqlalchemy.schema import Table
from sqlalchemy.sql.compiler import SQLCompiler
from sqlalchemy.types import Integer
from pushmanager.core import db
from pushmanager.testing import testdb
from pushmanager.testing.mocksettings import MockedSettings
from pushmanager.testing.testdb import FakeDataMixin
        first_push = self.make_push_dict(self.push_data[0])
        T.assert_equal(pushes[0].title, first_push['title'])

    def test_transaction_with_successful_condition(self):
        def on_return(success, _):
            assert success

        requestid = 1

        db.execute_transaction_cb(
            [db.push_pushcontents.insert({'request': 2, 'push': 2})],
            on_return,
            condition=(
                db.push_pushcontents.select(
                    db.push_pushcontents.c.request == requestid
                ),
                lambda results: results.fetchone().request == requestid
            )
        )

    def test_transaction_with_unsuccessful_condition(self):
        def on_return(success, _):
            # Transaction should fail since the condition will not be
            # successful
            T.assert_equal(success, False)

        # This will fail better not log errors
        with mock.patch("%s.db.logging.error" % __name__):
            db.execute_transaction_cb(
                [db.push_pushcontents.insert({'request': 2, 'push': 2})],

# Path: pushmanager/core/db.py
# def UnsignedInteger():
# def init_db():
# def finalize_db():
# def execute_cb(query, callback_fn):
# def execute_transaction_cb(queries, callback_fn, condition=None):
# def prefix_insert_ignore(insert_ignore, compiler, **kw):
# def prefix_insert_ignore_sqlite(insert_ignore, compiler, **kw):
# class DatabaseError(Exception):
# class PushCheckList(Base):
# class PushPlans(Base):
# class PushPushContents(Base):
# class PushPushes(Base):
# class PushRemovals(Base):
# class PushRequests(Base):
# class InsertIgnore(Insert):
# 
# Path: pushmanager/testing/mocksettings.py



# Path: pushmanager/tests/test_core_db.py
import os
import sqlalchemy as SA
import mock
import testify as T
from sqlalchemy.schema import Column
from sqlalchemy.schema import Table
from sqlalchemy.sql.compiler import SQLCompiler
from sqlalchemy.types import Integer
from pushmanager.core import db
from pushmanager.testing import testdb
from pushmanager.testing.mocksettings import MockedSettings
from pushmanager.testing.testdb import FakeDataMixin

        first_push = self.make_push_dict(self.push_data[0])
        T.assert_equal(pushes[0].title, first_push['title'])

    def test_transaction_with_successful_condition(self):
        def on_return(success, _):
            assert success

        requestid = 1

        db.execute_transaction_cb(
            [db.push_pushcontents.insert({'request': 2, 'push': 2})],
            on_return,
            condition=(
                db.push_pushcontents.select(
                    db.push_pushcontents.c.request == requestid
                ),
                lambda results: results.fetchone().request == requestid
            )
        )

    def test_transaction_with_unsuccessful_condition(self):
        def on_return(success, _):
            # Transaction should fail since the condition will not be
            # successful
            T.assert_equal(success, False)

        # This will fail better not log errors
        with mock.patch("%s.db.logging.error" % __name__):
            db.execute_transaction_cb(
                [db.push_pushcontents.insert({'request': 2, 'push': 2})],

                on_return,