# 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 types
import mock
import testify as T
from contextlib import nested
from pushmanager.core import db
from pushmanager.core.util import get_servlet_urlspec
from pushmanager.servlets.discardrequest import DiscardRequestServlet
from pushmanager.testing.mocksettings import MockedSettings
from pushmanager.testing.testservlet import ServletTestMixin
        mocked_self.check_db_results = mock.Mock(return_value=None)

        mocked_self.on_db_complete = types.MethodType(DiscardRequestServlet.on_db_complete.im_func, mocked_self)

        def first():
            return req

        mreq = mock.Mock()
        mreq.first = first

        mocked_self.on_db_complete('success', [mock.ANY, mreq])

    @mock.patch('pushmanager.core.mail.MailQueue.enqueue_user_email')
    def test_no_watched_mailqueue_on_db_complete(self, mailq):
        req = {
            'user': 'testuser',
            'watchers': None,
            'repo': 'repo',
            'branch': 'branch',
            'title': 'title',
            'state': 'discarded',
        }
        self.call_on_db_complete(req)

        no_watcher_call_args = mailq.call_args_list[0][0]
        T.assert_equal(['testuser'], no_watcher_call_args[0])
        T.assert_in('Request for testuser', no_watcher_call_args[1])
        T.assert_in('testuser - title', no_watcher_call_args[1])
        T.assert_in('[push] testuser - title', no_watcher_call_args[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_servlet_discardrequest.py
import types
import mock
import testify as T
from contextlib import nested
from pushmanager.core import db
from pushmanager.core.util import get_servlet_urlspec
from pushmanager.servlets.discardrequest import DiscardRequestServlet
from pushmanager.testing.mocksettings import MockedSettings
from pushmanager.testing.testservlet import ServletTestMixin

        mocked_self.check_db_results = mock.Mock(return_value=None)

        mocked_self.on_db_complete = types.MethodType(DiscardRequestServlet.on_db_complete.im_func, mocked_self)

        def first():
            return req

        mreq = mock.Mock()
        mreq.first = first

        mocked_self.on_db_complete('success', [mock.ANY, mreq])

    @mock.patch('pushmanager.core.mail.MailQueue.enqueue_user_email')
    def test_no_watched_mailqueue_on_db_complete(self, mailq):
        req = {
            'user': 'testuser',
            'watchers': None,
            'repo': 'repo',
            'branch': 'branch',
            'title': 'title',
            'state': 'discarded',
        }
        self.call_on_db_complete(req)

        no_watcher_call_args = mailq.call_args_list[0][0]
        T.assert_equal(['testuser'], no_watcher_call_args[0])
        T.assert_in('Request for testuser', no_watcher_call_args[1])
        T.assert_in('testuser - title', no_watcher_call_args[1])
        T.assert_in('[push] testuser - title', no_watcher_call_args[2])


    @mock.patch('pushmanager.core.mail.MailQueue.enqueue_user_email')