# Path: deckhand/factories.py
# LOG = logging.getLogger(__name__)
# DOCUMENT_TEST_SCHEMA = 'example/Kind/v1'
#     DATA_SCHEMA_TEMPLATE = {
#         "data": {
#             "$schema": ""
#         },
#         "metadata": {
#             "schema": "metadata/Control/v1",
#             "name": "",
#             "labels": {},
#             "layeringDefinition": {
#                 "abstract": True,
#                 "layer": "site"
#             }
#         },
#         "schema": "deckhand/DataSchema/v1"
#     }
#     LAYERING_POLICY_TEMPLATE = {
#         "data": {
#             "layerOrder": []
#         },
#         "metadata": {
#             "name": "placeholder",
#             "schema": "metadata/Control/v1",
#             "layeringDefinition": {
#                 "abstract": False,
#                 "layer": "layer"
#             }
#         },
#         "schema": "deckhand/LayeringPolicy/v1"
#     }
#     DOCUMENT_TEMPLATE = {
#         "data": {},
#         "metadata": {
#             "labels": {"": ""},
#             "layeringDefinition": {
#                 "abstract": False,
#                 "layer": "layer"
#             },
#             "name": "",
#             "schema": "metadata/Document/v1"
#         },
#         "schema": DOCUMENT_TEST_SCHEMA
#     }
#     DOCUMENT_SECRET_TEMPLATE = {
#         "data": {
#         },
#         "metadata": {
#             "schema": "metadata/Document/v1",
#             "name": "",
#             "layeringDefinition": {
#                 "abstract": False,
#                 "layer": "site"
#             },
#             "storagePolicy": "",
#         },
#         "schema": "deckhand/%s/v1"
#     }
# class DeckhandFactory(object):
# class DataSchemaFactory(DeckhandFactory):
# class DocumentFactory(DeckhandFactory):
# class DocumentSecretFactory(DeckhandFactory):
#     def gen_test(self, *args, **kwargs):
#     def __init__(self):
#     def gen_test(self, metadata_name, data, **metadata_labels):
#     def __init__(self, num_layers, docs_per_layer):
#     def gen_test(self, mapping, site_abstract=True, region_abstract=True,
#                  global_abstract=True, site_parent_selectors=None):
#     def __init__(self):
#     def gen_test(self, schema, storage_policy, data=None, name=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):


from deckhand import factories
from deckhand.tests import test_utils
from deckhand.tests.unit.db import base
        documents = self.create_documents(bucket_name, payload[0])
        # The first document will be first, followed by the two deleted docs.
        documents = sorted(documents, key=lambda d: (d['deleted'], d['name']))
        # Information about the deleted and created document should've been
        # returned. The 1st document is the deleted one and the 2nd document
        # is the created one.
        self.assertEqual(3, len(documents))
        self.assertFalse(documents[0]['deleted'])
        self.assertFalse(documents[0]['deleted_at'])
        self.assertTrue(documents[1]['deleted'])
        self.assertTrue(documents[2]['deleted'])
        self.assertTrue(documents[1]['deleted_at'])
        self.assertTrue(documents[2]['deleted_at'])

        for idx in range(1, 3):
            self.assertEqual(documents[idx]['schema'], payload[idx]['schema'])
            self.assertEqual(documents[idx]['name'],
                             payload[idx]['metadata']['name'])
            self.assertEmpty(documents[idx]['data'])

    def test_create_duplicate_bucket(self):
        """Validates that creating a bucket with the exact same documents
        references the last revision via orig_revision_id, as in reality
        the bucket is merely a revision history placeholder for the first
        bucket, since nothing was changed.

        Note that this is different from creating a duplicate document or
        creating a duplicate document in a separate bucket.

        """

# Path: deckhand/factories.py
# LOG = logging.getLogger(__name__)
# DOCUMENT_TEST_SCHEMA = 'example/Kind/v1'
#     DATA_SCHEMA_TEMPLATE = {
#         "data": {
#             "$schema": ""
#         },
#         "metadata": {
#             "schema": "metadata/Control/v1",
#             "name": "",
#             "labels": {},
#             "layeringDefinition": {
#                 "abstract": True,
#                 "layer": "site"
#             }
#         },
#         "schema": "deckhand/DataSchema/v1"
#     }
#     LAYERING_POLICY_TEMPLATE = {
#         "data": {
#             "layerOrder": []
#         },
#         "metadata": {
#             "name": "placeholder",
#             "schema": "metadata/Control/v1",
#             "layeringDefinition": {
#                 "abstract": False,
#                 "layer": "layer"
#             }
#         },
#         "schema": "deckhand/LayeringPolicy/v1"
#     }
#     DOCUMENT_TEMPLATE = {
#         "data": {},
#         "metadata": {
#             "labels": {"": ""},
#             "layeringDefinition": {
#                 "abstract": False,
#                 "layer": "layer"
#             },
#             "name": "",
#             "schema": "metadata/Document/v1"
#         },
#         "schema": DOCUMENT_TEST_SCHEMA
#     }
#     DOCUMENT_SECRET_TEMPLATE = {
#         "data": {
#         },
#         "metadata": {
#             "schema": "metadata/Document/v1",
#             "name": "",
#             "layeringDefinition": {
#                 "abstract": False,
#                 "layer": "site"
#             },
#             "storagePolicy": "",
#         },
#         "schema": "deckhand/%s/v1"
#     }
# class DeckhandFactory(object):
# class DataSchemaFactory(DeckhandFactory):
# class DocumentFactory(DeckhandFactory):
# class DocumentSecretFactory(DeckhandFactory):
#     def gen_test(self, *args, **kwargs):
#     def __init__(self):
#     def gen_test(self, metadata_name, data, **metadata_labels):
#     def __init__(self, num_layers, docs_per_layer):
#     def gen_test(self, mapping, site_abstract=True, region_abstract=True,
#                  global_abstract=True, site_parent_selectors=None):
#     def __init__(self):
#     def gen_test(self, schema, storage_policy, data=None, name=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_documents.py
from deckhand import factories
from deckhand.tests import test_utils
from deckhand.tests.unit.db import base

        documents = self.create_documents(bucket_name, payload[0])
        # The first document will be first, followed by the two deleted docs.
        documents = sorted(documents, key=lambda d: (d['deleted'], d['name']))
        # Information about the deleted and created document should've been
        # returned. The 1st document is the deleted one and the 2nd document
        # is the created one.
        self.assertEqual(3, len(documents))
        self.assertFalse(documents[0]['deleted'])
        self.assertFalse(documents[0]['deleted_at'])
        self.assertTrue(documents[1]['deleted'])
        self.assertTrue(documents[2]['deleted'])
        self.assertTrue(documents[1]['deleted_at'])
        self.assertTrue(documents[2]['deleted_at'])

        for idx in range(1, 3):
            self.assertEqual(documents[idx]['schema'], payload[idx]['schema'])
            self.assertEqual(documents[idx]['name'],
                             payload[idx]['metadata']['name'])
            self.assertEmpty(documents[idx]['data'])

    def test_create_duplicate_bucket(self):
        """Validates that creating a bucket with the exact same documents
        references the last revision via orig_revision_id, as in reality
        the bucket is merely a revision history placeholder for the first
        bucket, since nothing was changed.

        Note that this is different from creating a duplicate document or
        creating a duplicate document in a separate bucket.

        """

        bucket_name = test_utils.rand_name('bucket')