# 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/db/base.py
# BASE_EXPECTED_FIELDS = ("created_at", "updated_at", "deleted_at", "deleted")
# DOCUMENT_EXPECTED_FIELDS = BASE_EXPECTED_FIELDS + (
#     "id", "schema", "name", "layer", "metadata", "data", "data_hash",
#     "metadata_hash", "revision_id", "bucket_id")
# REVISION_EXPECTED_FIELDS = ("id", "documents", "tags")
# class DocumentFixture(object):
# class TestDbBase(base.DeckhandWithDBTestCase):
#     def get_minimal_fixture(**kwargs):
#     def get_minimal_multi_fixture(count=2, **kwargs):
#     def create_documents(self, bucket_name, documents,
#                          validation_policies=None):
#     def show_document(self, **fields):
#     def create_revision(self):
#     def show_revision(self, revision_id):
#     def delete_revisions(self):
#     def list_revision_documents(self, revision_id, **filters):
#     def list_revisions(self):
#     def rollback_revision(self, revision_id):
#     def create_validation(self, revision_id, val_name, val_data):
#     def _validate_object(self, obj):
#     def validate_document(self, actual, expected=None, is_deleted=False):
#     def validate_revision(self, revision):


import copy
from deckhand.db.sqlalchemy import api as db_api
from deckhand.tests import test_utils
from deckhand.tests.unit.db import base
        comparison_revision_id = deleted_documents[0]['revision_id']

        self._verify_buckets_status(
            revision_id, comparison_revision_id, {bucket_name: 'deleted'})

    def test_revision_diff_delete_then_recreate(self):
        payload = base.DocumentFixture.get_minimal_fixture()
        bucket_name = test_utils.rand_name('bucket')
        created_documents = self.create_documents(bucket_name, payload)
        revision_id_1 = created_documents[0]['revision_id']

        # Delete the previously created document.
        deleted_documents = self.create_documents(bucket_name, [])
        revision_id_2 = deleted_documents[0]['revision_id']

        # Recreate the previously deleted document.
        recreated_documents = self.create_documents(bucket_name, payload)
        revision_id_3 = recreated_documents[0]['revision_id']

        # Verify that the revision for recreated document compared to revision
        # for deleted document is created, ignoring order.
        self._verify_buckets_status(
            revision_id_2, revision_id_3, {bucket_name: 'created'})

        # Verify that the revision for recreated document compared to revision
        # for created document is unmodified, ignoring order.
        self._verify_buckets_status(
            revision_id_1, revision_id_3, {bucket_name: 'unmodified'})

    def test_revision_diff_ignore_mistake_document(self):

# 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/db/base.py
# BASE_EXPECTED_FIELDS = ("created_at", "updated_at", "deleted_at", "deleted")
# DOCUMENT_EXPECTED_FIELDS = BASE_EXPECTED_FIELDS + (
#     "id", "schema", "name", "layer", "metadata", "data", "data_hash",
#     "metadata_hash", "revision_id", "bucket_id")
# REVISION_EXPECTED_FIELDS = ("id", "documents", "tags")
# class DocumentFixture(object):
# class TestDbBase(base.DeckhandWithDBTestCase):
#     def get_minimal_fixture(**kwargs):
#     def get_minimal_multi_fixture(count=2, **kwargs):
#     def create_documents(self, bucket_name, documents,
#                          validation_policies=None):
#     def show_document(self, **fields):
#     def create_revision(self):
#     def show_revision(self, revision_id):
#     def delete_revisions(self):
#     def list_revision_documents(self, revision_id, **filters):
#     def list_revisions(self):
#     def rollback_revision(self, revision_id):
#     def create_validation(self, revision_id, val_name, val_data):
#     def _validate_object(self, obj):
#     def validate_document(self, actual, expected=None, is_deleted=False):
#     def validate_revision(self, revision):


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

        comparison_revision_id = deleted_documents[0]['revision_id']

        self._verify_buckets_status(
            revision_id, comparison_revision_id, {bucket_name: 'deleted'})

    def test_revision_diff_delete_then_recreate(self):
        payload = base.DocumentFixture.get_minimal_fixture()
        bucket_name = test_utils.rand_name('bucket')
        created_documents = self.create_documents(bucket_name, payload)
        revision_id_1 = created_documents[0]['revision_id']

        # Delete the previously created document.
        deleted_documents = self.create_documents(bucket_name, [])
        revision_id_2 = deleted_documents[0]['revision_id']

        # Recreate the previously deleted document.
        recreated_documents = self.create_documents(bucket_name, payload)
        revision_id_3 = recreated_documents[0]['revision_id']

        # Verify that the revision for recreated document compared to revision
        # for deleted document is created, ignoring order.
        self._verify_buckets_status(
            revision_id_2, revision_id_3, {bucket_name: 'created'})

        # Verify that the revision for recreated document compared to revision
        # for created document is unmodified, ignoring order.
        self._verify_buckets_status(
            revision_id_1, revision_id_3, {bucket_name: 'unmodified'})

    def test_revision_diff_ignore_mistake_document(self):

        payload = base.DocumentFixture.get_minimal_fixture()