# 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 copy
import os
import mock
import pushmanager.core.git
import shutil
import tempfile
import testify as T
from contextlib import contextmanager
from contextlib import nested
from pushmanager.core import db
from pushmanager.core.git import GitCommand
from pushmanager.core.git import GitException
from pushmanager.core.git import GitQueue
from pushmanager.core.git import GitTaskAction
from pushmanager.core.settings import Settings
from pushmanager.testing import testdb
from pushmanager.testing.mocksettings import MockedSettings
                )
                db.execute_cb(request_info_query, on_db_return)
                T.assert_equal(result[0][5], new_sha)
                T.assert_equals(enqueue_req.call_count, 2)
                enqueue_req.assert_has_calls([
                    mock.call(
                        GitTaskAction.TEST_PICKME_CONFLICT,
                        1,
                        pushmanager_url='https://%s:%s' % (
                            MockedSettings['main_app']['servername'],
                            MockedSettings['main_app']['port']
                        )
                    )
                ])

    def test_update_req_sha_and_queue_pickme_added_test_conflicting_pickmes(self):
        new_sha = "1"*40
        pickme_request = copy.deepcopy(self.fake_request)
        pickme_request['state'] = 'added'
        pickme_request['tags'] = 'conflict-pickme'
        with mock.patch('pushmanager.core.git.GitQueue.enqueue_request') as enqueue_req:
            with mock.patch.dict(Settings, MockedSettings):
                GitQueue._update_req_sha_and_queue_pickme(pickme_request, new_sha)

                result = [None]

                def on_db_return(success, db_results):
                    assert success, "Database error"
                    result[0] = db_results.first()


# 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_git.py
import copy
import os
import mock
import pushmanager.core.git
import shutil
import tempfile
import testify as T
from contextlib import contextmanager
from contextlib import nested
from pushmanager.core import db
from pushmanager.core.git import GitCommand
from pushmanager.core.git import GitException
from pushmanager.core.git import GitQueue
from pushmanager.core.git import GitTaskAction
from pushmanager.core.settings import Settings
from pushmanager.testing import testdb
from pushmanager.testing.mocksettings import MockedSettings

                )
                db.execute_cb(request_info_query, on_db_return)
                T.assert_equal(result[0][5], new_sha)
                T.assert_equals(enqueue_req.call_count, 2)
                enqueue_req.assert_has_calls([
                    mock.call(
                        GitTaskAction.TEST_PICKME_CONFLICT,
                        1,
                        pushmanager_url='https://%s:%s' % (
                            MockedSettings['main_app']['servername'],
                            MockedSettings['main_app']['port']
                        )
                    )
                ])

    def test_update_req_sha_and_queue_pickme_added_test_conflicting_pickmes(self):
        new_sha = "1"*40
        pickme_request = copy.deepcopy(self.fake_request)
        pickme_request['state'] = 'added'
        pickme_request['tags'] = 'conflict-pickme'
        with mock.patch('pushmanager.core.git.GitQueue.enqueue_request') as enqueue_req:
            with mock.patch.dict(Settings, MockedSettings):
                GitQueue._update_req_sha_and_queue_pickme(pickme_request, new_sha)

                result = [None]

                def on_db_return(success, db_results):
                    assert success, "Database error"
                    result[0] = db_results.first()


                request_info_query = db.push_requests.select().where(