# 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 re
import urllib
import mock
import testify as T
from contextlib import contextmanager
from contextlib import nested
from pushmanager.core import db
from pushmanager.core.util import get_servlet_urlspec
from pushmanager.servlets.checklist import ChecklistServlet
from pushmanager.servlets.checklist import ChecklistToggleServlet
from pushmanager.testing.mocksettings import MockedSettings
from pushmanager.testing.testdb import FakeDataMixin
from pushmanager.testing.testservlet import ServletTestMixin
            T.assert_equal(response.error, None)
            T.assert_not_in("No checklist items for this push", response.body)
            T.assert_in("Notify testuser1 to deploy Geoservices to stage", response.body)
            T.assert_in("Notify testuser1 to deploy Geoservices to prod", response.body)


class ChecklistToggleServletTest(T.TestCase, ServletTestMixin, FakeDataMixin):

    def get_handlers(self):
        return [get_servlet_urlspec(ChecklistToggleServlet)]

    def test_checklist_toggle_post(self):
        complete = 0
        checklist_item = [None]

        def check_toggle(success, db_results):
            assert success
            checklist_item[0] = db_results.fetchone()
            T.assert_equal(checklist_item[0]['complete'], complete)

        with fake_checklist_request():
            # insert fake data from FakeDataMixin
            self.insert_requests()
            test_request1 = self.get_requests_by_user('testuser1')[0]
            # insert fake checklist data
            checklist_query = db.push_checklist.insert({
                'request': test_request1['id'],
                'type': 'search',
                'target': 'prod'
            })

# 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_checklist.py
import re
import urllib
import mock
import testify as T
from contextlib import contextmanager
from contextlib import nested
from pushmanager.core import db
from pushmanager.core.util import get_servlet_urlspec
from pushmanager.servlets.checklist import ChecklistServlet
from pushmanager.servlets.checklist import ChecklistToggleServlet
from pushmanager.testing.mocksettings import MockedSettings
from pushmanager.testing.testdb import FakeDataMixin
from pushmanager.testing.testservlet import ServletTestMixin

            T.assert_equal(response.error, None)
            T.assert_not_in("No checklist items for this push", response.body)
            T.assert_in("Notify testuser1 to deploy Geoservices to stage", response.body)
            T.assert_in("Notify testuser1 to deploy Geoservices to prod", response.body)


class ChecklistToggleServletTest(T.TestCase, ServletTestMixin, FakeDataMixin):

    def get_handlers(self):
        return [get_servlet_urlspec(ChecklistToggleServlet)]

    def test_checklist_toggle_post(self):
        complete = 0
        checklist_item = [None]

        def check_toggle(success, db_results):
            assert success
            checklist_item[0] = db_results.fetchone()
            T.assert_equal(checklist_item[0]['complete'], complete)

        with fake_checklist_request():
            # insert fake data from FakeDataMixin
            self.insert_requests()
            test_request1 = self.get_requests_by_user('testuser1')[0]
            # insert fake checklist data
            checklist_query = db.push_checklist.insert({
                'request': test_request1['id'],
                'type': 'search',
                'target': 'prod'
            })

            db.execute_cb(checklist_query, on_db_return)