# Path: deckhand/conf/config.py
# CONF = cfg.CONF
# def register_opts(conf):
# def list_opts():
# 
# Path: deckhand/db/sqlalchemy/api.py
# LOG = logging.getLogger(__name__)
# CONF = cfg.CONF
# _FACADE = None
# _LOCK = threading.Lock()
#                 _FACADE = session.EngineFacade.from_config(
#                     CONF, sqlite_fk=True)
# def _create_facade_lazily():
# def get_engine():
# def get_session(autocommit=True, expire_on_commit=False):
# def drop_db():
# def setup_db(connection_string, create_tables=False):
# def raw_query(query, **kwargs):
# def require_unique_document_schema(schema=None):
#     def decorator(f):
#         def wrapper(bucket_name, documents, *args, **kwargs):
# def documents_create(bucket_name, documents, validations=None,
#                      session=None):
# def _documents_create(bucket_name, documents, session=None):
#     def _document_create(document):
# def _fill_in_metadata_defaults(document):
# def _make_hash(data):
# def document_get(session=None, raw_dict=False, revision_id=None, **filters):
# def document_get_all(session=None, raw_dict=False, revision_id=None,
#                      **filters):
# def bucket_get_or_create(bucket_name, session=None):
# def revision_create(session=None):
# def revision_get(revision_id=None, session=None):
# def revision_get_latest(session=None):
# def require_revision_exists(f):
#     def wrapper(revision_id=None, *args, **kwargs):
# def _update_revision_history(documents):
# def revision_get_all(session=None, **filters):
# def revision_delete_all():
# def _exclude_deleted_documents(documents):
# def _filter_revision_documents(documents, unique_only, **filters):
# def revision_documents_get(revision_id=None, include_history=True,
#                            unique_only=True, session=None, **filters):
# def revision_diff(revision_id, comparison_revision_id):
#     def _compare_buckets(b1, b2):
# def revision_tag_create(revision_id, tag, data=None, session=None):
# def revision_tag_get(revision_id, tag, session=None):
# def revision_tag_get_all(revision_id, session=None):
# def revision_tag_delete(revision_id, tag, session=None):
# def revision_tag_delete_all(revision_id, session=None):
# def revision_rollback(revision_id, latest_revision, session=None):
# def _get_validation_policies_for_revision(revision_id, session=None):
# def validation_create(revision_id, val_name, val_data, session=None):
# def validation_get_all(revision_id, session=None):
# def _check_validation_entries_against_validation_policies(
#         revision_id, entries, val_name=None, session=None):
# def validation_get_all_entries(revision_id, val_name=None, session=None):
# def validation_get_entry(revision_id, val_name, entry_id, session=None):
# 
# Path: deckhand/tests/unit/fixtures.py
# CONF = cfg.CONF
# class ConfPatcher(fixtures.Fixture):
# class RealPolicyFixture(fixtures.Fixture):
#     def __init__(self, **kwargs):
#     def setUp(self):
#     def __init__(self, verify=True, *args, **kwargs):
#     def _setUp(self):
#     def _verify_policies_match(self):
#     def _install_policy_verification_hook(self):
#         def enforce_policy_and_remember_actual_rules(
#                 action, *a, **k):
#     def add_missing_default_rules(self, rules):
#     def set_rules(self, rules, overwrite=True):


import os
import fixtures
import mock
import testtools
from oslo_config import cfg
from oslo_log import log as logging
from deckhand.conf import config  # noqa: Calls register_opts(CONF)
from deckhand.db.sqlalchemy import api as db_api
from deckhand.tests.unit import fixtures as dh_fixtures
        :param target: String module.class or module.object expression to patch
        :param **kwargs: Passed as-is to `mock.patch`. See mock documentation
                         for details.
        """
        p = mock.patch(target, autospec=autospec, **kwargs)
        m = p.start()
        self.addCleanup(p.stop)
        return m

    def patchobject(self, target, attribute, new=mock.DEFAULT, **kwargs):
        """Convenient wrapper around `mock.patch.object`

        Returns a started mock that will be automatically stopped after the
        test ran.
        """

        p = mock.patch.object(target, attribute, new, **kwargs)
        m = p.start()
        self.addCleanup(p.stop)
        return m


class DeckhandWithDBTestCase(DeckhandTestCase):

    def setUp(self):
        super(DeckhandWithDBTestCase, self).setUp()
        self.override_config(
            'connection', os.environ.get('PIFPAF_URL', 'sqlite://'),
            group='database')
        db_api.setup_db(CONF.database.connection, create_tables=True)

# Path: deckhand/conf/config.py
# CONF = cfg.CONF
# def register_opts(conf):
# def list_opts():
# 
# Path: deckhand/db/sqlalchemy/api.py
# LOG = logging.getLogger(__name__)
# CONF = cfg.CONF
# _FACADE = None
# _LOCK = threading.Lock()
#                 _FACADE = session.EngineFacade.from_config(
#                     CONF, sqlite_fk=True)
# def _create_facade_lazily():
# def get_engine():
# def get_session(autocommit=True, expire_on_commit=False):
# def drop_db():
# def setup_db(connection_string, create_tables=False):
# def raw_query(query, **kwargs):
# def require_unique_document_schema(schema=None):
#     def decorator(f):
#         def wrapper(bucket_name, documents, *args, **kwargs):
# def documents_create(bucket_name, documents, validations=None,
#                      session=None):
# def _documents_create(bucket_name, documents, session=None):
#     def _document_create(document):
# def _fill_in_metadata_defaults(document):
# def _make_hash(data):
# def document_get(session=None, raw_dict=False, revision_id=None, **filters):
# def document_get_all(session=None, raw_dict=False, revision_id=None,
#                      **filters):
# def bucket_get_or_create(bucket_name, session=None):
# def revision_create(session=None):
# def revision_get(revision_id=None, session=None):
# def revision_get_latest(session=None):
# def require_revision_exists(f):
#     def wrapper(revision_id=None, *args, **kwargs):
# def _update_revision_history(documents):
# def revision_get_all(session=None, **filters):
# def revision_delete_all():
# def _exclude_deleted_documents(documents):
# def _filter_revision_documents(documents, unique_only, **filters):
# def revision_documents_get(revision_id=None, include_history=True,
#                            unique_only=True, session=None, **filters):
# def revision_diff(revision_id, comparison_revision_id):
#     def _compare_buckets(b1, b2):
# def revision_tag_create(revision_id, tag, data=None, session=None):
# def revision_tag_get(revision_id, tag, session=None):
# def revision_tag_get_all(revision_id, session=None):
# def revision_tag_delete(revision_id, tag, session=None):
# def revision_tag_delete_all(revision_id, session=None):
# def revision_rollback(revision_id, latest_revision, session=None):
# def _get_validation_policies_for_revision(revision_id, session=None):
# def validation_create(revision_id, val_name, val_data, session=None):
# def validation_get_all(revision_id, session=None):
# def _check_validation_entries_against_validation_policies(
#         revision_id, entries, val_name=None, session=None):
# def validation_get_all_entries(revision_id, val_name=None, session=None):
# def validation_get_entry(revision_id, val_name, entry_id, session=None):
# 
# Path: deckhand/tests/unit/fixtures.py
# CONF = cfg.CONF
# class ConfPatcher(fixtures.Fixture):
# class RealPolicyFixture(fixtures.Fixture):
#     def __init__(self, **kwargs):
#     def setUp(self):
#     def __init__(self, verify=True, *args, **kwargs):
#     def _setUp(self):
#     def _verify_policies_match(self):
#     def _install_policy_verification_hook(self):
#         def enforce_policy_and_remember_actual_rules(
#                 action, *a, **k):
#     def add_missing_default_rules(self, rules):
#     def set_rules(self, rules, overwrite=True):


# Path: deckhand/tests/unit/base.py
import os
import fixtures
import mock
import testtools
from oslo_config import cfg
from oslo_log import log as logging
from deckhand.conf import config  # noqa: Calls register_opts(CONF)
from deckhand.db.sqlalchemy import api as db_api
from deckhand.tests.unit import fixtures as dh_fixtures

        :param target: String module.class or module.object expression to patch
        :param **kwargs: Passed as-is to `mock.patch`. See mock documentation
                         for details.
        """
        p = mock.patch(target, autospec=autospec, **kwargs)
        m = p.start()
        self.addCleanup(p.stop)
        return m

    def patchobject(self, target, attribute, new=mock.DEFAULT, **kwargs):
        """Convenient wrapper around `mock.patch.object`

        Returns a started mock that will be automatically stopped after the
        test ran.
        """

        p = mock.patch.object(target, attribute, new, **kwargs)
        m = p.start()
        self.addCleanup(p.stop)
        return m


class DeckhandWithDBTestCase(DeckhandTestCase):

    def setUp(self):
        super(DeckhandWithDBTestCase, self).setUp()
        self.override_config(
            'connection', os.environ.get('PIFPAF_URL', 'sqlite://'),
            group='database')
        db_api.setup_db(CONF.database.connection, create_tables=True)

        self.addCleanup(db_api.drop_db)