# 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
        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)

    @patch('tools.rename_checklist_type.convert_checklist')
    @patch('optparse.OptionParser.error')
    @patch('optparse.OptionParser.parse_args', return_value=[None, []])
    def test_main_noargs(self, parser, error, convert_checklist):
        rename_checklist_type.main()
        T.assert_equal(False, convert_checklist.called)
        error.assert_called_once_with('Incorrect number of arguments')

    @patch('tools.rename_checklist_type.convert_checklist')
    @patch('optparse.OptionParser.error')
    @patch(
        'optparse.OptionParser.parse_args',
        return_value=[None, ['oldtag', 'newtag']]
    )
    def test_main_twoargs(self, parser, error, convert_checklist):
        parser.return_value = [None, ['oldtag', 'newtag']]
        rename_checklist_type.main()
        convert_checklist.assert_called_once_with('oldtag', 'newtag')
        T.assert_equal(False, error.called)

    def test_convert_cleanup_type(self):
        rename_checklist_type.convert_checklist('search', 'not_search')
        cb = partial(self.verify_type_rename, 'search', 'not_search')
        db.execute_cb(db.push_checklist.select(), cb)

    def test_convert_notype(self):

# 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

        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)

    @patch('tools.rename_checklist_type.convert_checklist')
    @patch('optparse.OptionParser.error')
    @patch('optparse.OptionParser.parse_args', return_value=[None, []])
    def test_main_noargs(self, parser, error, convert_checklist):
        rename_checklist_type.main()
        T.assert_equal(False, convert_checklist.called)
        error.assert_called_once_with('Incorrect number of arguments')

    @patch('tools.rename_checklist_type.convert_checklist')
    @patch('optparse.OptionParser.error')
    @patch(
        'optparse.OptionParser.parse_args',
        return_value=[None, ['oldtag', 'newtag']]
    )
    def test_main_twoargs(self, parser, error, convert_checklist):
        parser.return_value = [None, ['oldtag', 'newtag']]
        rename_checklist_type.main()
        convert_checklist.assert_called_once_with('oldtag', 'newtag')
        T.assert_equal(False, error.called)

    def test_convert_cleanup_type(self):
        rename_checklist_type.convert_checklist('search', 'not_search')
        cb = partial(self.verify_type_rename, 'search', 'not_search')
        db.execute_cb(db.push_checklist.select(), cb)

    def test_convert_notype(self):

        rename_checklist_type.convert_checklist('nonexistent', 'random')