# 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: tools/rename_checklist_type.py
# def main():
# def convert_checklist(old, new):
# def convert_checklist_callback(old, new, success, db_results):
# def check_db_results(success, db_results):


import os
import testify as T
from functools import partial
from mock import patch
from pushmanager.core import db
from pushmanager.testing import testdb
from pushmanager.testing.mocksettings import MockedSettings
from pushmanager.testing.testdb import FakeDataMixin
from tools import rename_checklist_type
            raise db.DatabaseError()

    def verify_database_state(self, data, success, db_results):
        self.check_db_results(success, db_results)

        # id, push, *type*, status, target
        data_types = [d[2] for d in data]
        # id, push, *type*, status, target
        types = [result[2] for result in db_results.fetchall()]

        T.assert_sorted_equal(data_types, types)

    def verify_type_rename(self, oldtype, newtype, success, db_results):
        self.check_db_results(success, db_results)

        # id, push, *type*, status, target
        types = [result[2] for result in db_results.fetchall()]

        T.assert_not_in(oldtype, types)
        T.assert_not_in('%s-cleanup' % oldtype, types)
        T.assert_in('%s' % newtype, types)
        T.assert_in('%s-cleanup' % newtype, types)

    def make_checklist_dict(self, data):
        return dict(zip(self.checklist_keys, data))

    def insert_checklists(self):
        checklist_queries = []
        for cl in self.checklist_data:
            checklist_queries.append(db.push_checklist.insert(self.make_checklist_dict(cl)))

# 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: tools/rename_checklist_type.py
# def main():
# def convert_checklist(old, new):
# def convert_checklist_callback(old, new, success, db_results):
# def check_db_results(success, db_results):


# Path: pushmanager/tests/test_rename_checklist_type.py
import os
import testify as T
from functools import partial
from mock import patch
from pushmanager.core import db
from pushmanager.testing import testdb
from pushmanager.testing.mocksettings import MockedSettings
from pushmanager.testing.testdb import FakeDataMixin
from tools import rename_checklist_type

            raise db.DatabaseError()

    def verify_database_state(self, data, success, db_results):
        self.check_db_results(success, db_results)

        # id, push, *type*, status, target
        data_types = [d[2] for d in data]
        # id, push, *type*, status, target
        types = [result[2] for result in db_results.fetchall()]

        T.assert_sorted_equal(data_types, types)

    def verify_type_rename(self, oldtype, newtype, success, db_results):
        self.check_db_results(success, db_results)

        # id, push, *type*, status, target
        types = [result[2] for result in db_results.fetchall()]

        T.assert_not_in(oldtype, types)
        T.assert_not_in('%s-cleanup' % oldtype, types)
        T.assert_in('%s' % newtype, types)
        T.assert_in('%s-cleanup' % newtype, types)

    def make_checklist_dict(self, data):
        return dict(zip(self.checklist_keys, data))

    def insert_checklists(self):
        checklist_queries = []
        for cl in self.checklist_data:
            checklist_queries.append(db.push_checklist.insert(self.make_checklist_dict(cl)))

        db.execute_transaction_cb(checklist_queries, self.on_db_return)