# Path: deckhand/control/views/document.py
# class ViewBuilder(common.ViewBuilder):
#     def list(self, documents):
# 
# 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.control.views import document
from deckhand.tests import test_utils
from deckhand.tests.unit.db import base
    def _test_document_creation_view(self, count):
        # Test document creation view with the number of documents being
        # created specified by `count`.
        payload = [base.DocumentFixture.get_minimal_fixture()
                   for _ in range(count)]
        bucket_name = test_utils.rand_name('bucket')
        created_documents = self.create_documents(bucket_name, payload)
        document_view = self.view_builder.list(created_documents)

        self.assertIsInstance(document_view, list)
        self.assertEqual(count, len(document_view))

        expected_attrs = ('id', 'status', 'metadata', 'data', 'schema')
        for idx in range(count):
            for attr in expected_attrs:
                self.assertIn(attr, document_view[idx])
            for attr in ('bucket', 'revision'):
                self.assertIn(attr, document_view[idx]['status'])

        revision_ids = set([v['status']['revision'] for v in document_view])
        self.assertEqual([1], list(revision_ids))

    def test_create_single_document(self):
        self._test_document_creation_view(1)

    def test_create_many_documents(self):
        self._test_document_creation_view(4)

    def test_delete_all_documents(self):
        payload = base.DocumentFixture.get_minimal_fixture()

# Path: deckhand/control/views/document.py
# class ViewBuilder(common.ViewBuilder):
#     def list(self, documents):
# 
# 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/views/test_document_views.py
from deckhand.control.views import document
from deckhand.tests import test_utils
from deckhand.tests.unit.db import base

    def _test_document_creation_view(self, count):
        # Test document creation view with the number of documents being
        # created specified by `count`.
        payload = [base.DocumentFixture.get_minimal_fixture()
                   for _ in range(count)]
        bucket_name = test_utils.rand_name('bucket')
        created_documents = self.create_documents(bucket_name, payload)
        document_view = self.view_builder.list(created_documents)

        self.assertIsInstance(document_view, list)
        self.assertEqual(count, len(document_view))

        expected_attrs = ('id', 'status', 'metadata', 'data', 'schema')
        for idx in range(count):
            for attr in expected_attrs:
                self.assertIn(attr, document_view[idx])
            for attr in ('bucket', 'revision'):
                self.assertIn(attr, document_view[idx]['status'])

        revision_ids = set([v['status']['revision'] for v in document_view])
        self.assertEqual([1], list(revision_ids))

    def test_create_single_document(self):
        self._test_document_creation_view(1)

    def test_create_many_documents(self):
        self._test_document_creation_view(4)

    def test_delete_all_documents(self):
        payload = base.DocumentFixture.get_minimal_fixture()

        bucket_name = test_utils.rand_name('bucket')