# 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/test_utils.py
# def rand_uuid_hex():
# def rand_name(name='', prefix='deckhand'):
# def rand_bool():
# def rand_int(min, max):
# def rand_password(length=15):
# 
# Path: deckhand/tests/unit/base.py
# CONF = cfg.CONF
# class DeckhandTestCase(testtools.TestCase):
# class DeckhandWithDBTestCase(DeckhandTestCase):
#     def setUp(self):
#     def override_config(self, name, override, group=None):
#     def assertEmpty(self, collection):
#     def assertDictItemsAlmostEqual(self, first, second, ignore):
#     def patch(self, target, autospec=True, **kwargs):
#     def patchobject(self, target, attribute, new=mock.DEFAULT, **kwargs):
#     def setUp(self):


from testtools import matchers
from deckhand.db.sqlalchemy import api as db_api
from deckhand.tests import test_utils
from deckhand.tests.unit import base

        return doc

    def create_revision(self):
        # Implicitly creates a revision and returns it.
        documents = [DocumentFixture.get_minimal_fixture()]
        bucket_name = test_utils.rand_name('bucket')
        revision_id = self.create_documents(bucket_name, documents)[0][
            'revision_id']
        return revision_id

    def show_revision(self, revision_id):
        revision = db_api.revision_get(revision_id)
        self.validate_revision(revision)
        return revision

    def delete_revisions(self):
        return db_api.revision_delete_all()

    def list_revision_documents(self, revision_id, **filters):
        documents = db_api.revision_documents_get(revision_id, **filters)
        for document in documents:
            self.validate_document(document)
        return documents

    def list_revisions(self):
        return db_api.revision_get_all()

    def rollback_revision(self, revision_id):
        latest_revision = db_api.revision_get_latest()

# 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/test_utils.py
# def rand_uuid_hex():
# def rand_name(name='', prefix='deckhand'):
# def rand_bool():
# def rand_int(min, max):
# def rand_password(length=15):
# 
# Path: deckhand/tests/unit/base.py
# CONF = cfg.CONF
# class DeckhandTestCase(testtools.TestCase):
# class DeckhandWithDBTestCase(DeckhandTestCase):
#     def setUp(self):
#     def override_config(self, name, override, group=None):
#     def assertEmpty(self, collection):
#     def assertDictItemsAlmostEqual(self, first, second, ignore):
#     def patch(self, target, autospec=True, **kwargs):
#     def patchobject(self, target, attribute, new=mock.DEFAULT, **kwargs):
#     def setUp(self):


# Path: deckhand/tests/unit/db/base.py
from testtools import matchers
from deckhand.db.sqlalchemy import api as db_api
from deckhand.tests import test_utils
from deckhand.tests.unit import base


        return doc

    def create_revision(self):
        # Implicitly creates a revision and returns it.
        documents = [DocumentFixture.get_minimal_fixture()]
        bucket_name = test_utils.rand_name('bucket')
        revision_id = self.create_documents(bucket_name, documents)[0][
            'revision_id']
        return revision_id

    def show_revision(self, revision_id):
        revision = db_api.revision_get(revision_id)
        self.validate_revision(revision)
        return revision

    def delete_revisions(self):
        return db_api.revision_delete_all()

    def list_revision_documents(self, revision_id, **filters):
        documents = db_api.revision_documents_get(revision_id, **filters)
        for document in documents:
            self.validate_document(document)
        return documents

    def list_revisions(self):
        return db_api.revision_get_all()

    def rollback_revision(self, revision_id):
        latest_revision = db_api.revision_get_latest()

        return db_api.revision_rollback(revision_id, latest_revision)