Repository: iiif-prezi/iiif-prezi3 (language: python)

Issue:
Make Collection
<!-- Add a short name of the proposed helper method in the Title above -->

## Description
<!-- Provide a short description of the helper method -->
This helper will create a new `Collection` object, add it to the `items` property (by calling the `add_item` helper (#37)), and return the new object

## Function name / Parameters / Return
<!-- Suggest a name for the helper's function, the parameters it should accept, and what it should return (if anything) -->
Function name: `.make_collection()`

Parameters: None

Returns: a `Collection` object

## Objects
<!-- Which objects should this helper apply to? -->
- [ ] Base Object (all Prezi3 Classes)
- [x] Collection
- [ ] Manifest
- [ ] Canvas
- [ ] Range
- [ ] AnnotationCollection
- [ ] AnnotationPage
- [ ] Annotation
- [ ] Content Resource - Image
- [ ] Content Resource - Video
- [ ] Content Resource - Text
- [ ] Service
- [ ] Provider
- [ ] Other - please list below
<!-- Add other Objects/Classes here -->

## Considerations
<!-- Any extra considerations for the behavior of this helper -->
Make Manifest
<!-- Add a short name of the proposed helper method in the Title above -->

## Description
<!-- Provide a short description of the helper method -->
This helper will create a new `Manifest` object, add it **by reference** to the `items` property, and return it

## Function name / Parameters / Return
<!-- Suggest a name for the helper's function, the parameters it should accept, and what it should return (if anything) -->
Function name: `make_manifest()`

Parameters: None

Returns: A `Manifest` object

## Objects
<!-- Which objects should this helper apply to? -->
- [ ] Base Object (all Prezi3 Classes)
- [x] Collection
- [ ] Manifest
- [ ] Canvas
- [ ] Range
- [ ] AnnotationCollection
- [ ] AnnotationPage
- [ ] Annotation
- [ ] Content Resource - Image
- [ ] Content Resource - Video
- [ ] Content Resource - Text
- [ ] Service
- [ ] Provider
- [ ] Other - please list below
<!-- Add other Objects/Classes here -->

## Considerations
<!-- Any extra considerations for the behavior of this helper -->
Manifests must not be embedded inline in a Collection (https://iiif.io/api/presentation/3.0/#51-collection) and therefore this helper must also create a `ManifestReference` and add _that_ to the `items` property of the `Collection` object calling this helper.



Discussion / hints:

Should add optional parameters of ID but also use the id generating code. 

Label would need to be required as a parameter. 
Potentially only a name change for this method:

https://github.com/iiif-prezi/iiif-prezi3/blob/main/iiif_prezi3/helpers/collection_add_methods.py

Fix patch:
diff --git a/iiif_prezi3/helpers/__init__.py b/iiif_prezi3/helpers/__init__.py
index 50d9a8d..5298588 100644
--- a/iiif_prezi3/helpers/__init__.py
+++ b/iiif_prezi3/helpers/__init__.py
@@ -5,6 +5,8 @@
 from .auto_fields import *  # noqa: F401,F403
 from .canvas_helpers import AddImageToCanvas  # noqa: F401
 from .canvas_sizes import MaxHelper, MinHelper  # noqa: F401
+from .make_collection import MakeCollection # noqa: F401
+from .make_manifest import MakeManifest # noqa: F401
 from .add_range import AddRange # noqa: F401
 from .set_hwd import SetHwd  # noqa: F401
 from .to_reference import ToReference  # noqa: F401
diff --git a/iiif_prezi3/helpers/make_collection.py b/iiif_prezi3/helpers/make_collection.py
new file mode 100644
index 0000000..1b9dee8
--- /dev/null
+++ b/iiif_prezi3/helpers/make_collection.py
@@ -0,0 +1,19 @@
+from ..loader import monkeypatch_schema
+from ..skeleton import Collection
+
+
+class MakeCollection:
+
+    def make_collection(self, **kwargs):
+        """
+        Creates a new collection, adds it to the calling Collection `items`
+        and returns the newly created object. Accepts keyword arguments to 
+        customize the resulting instance.
+        """
+
+        child_collection = Collection(**kwargs)
+        self.add_item(child_collection)
+        return child_collection
+
+
+monkeypatch_schema(Collection, MakeCollection)
diff --git a/iiif_prezi3/helpers/make_manifest.py b/iiif_prezi3/helpers/make_manifest.py
new file mode 100644
index 0000000..c447440
--- /dev/null
+++ b/iiif_prezi3/helpers/make_manifest.py
@@ -0,0 +1,19 @@
+from ..loader import monkeypatch_schema
+from ..skeleton import Collection, Manifest
+
+
+class MakeManifest:
+
+    def make_manifest(self, **kwargs):
+        """
+        Creates a new Manifest, adds a Reference to it to the 
+        calling Collection items and returns the newly created Manifest.
+        Accepts keyword arguments to customize the resulting instance.
+        """
+
+        manifest = Manifest(**kwargs)
+        self.add_item(manifest)
+        return manifest
+
+
+monkeypatch_schema(Collection, MakeManifest)


Test patch:
diff --git a/tests/test_make_collection.py b/tests/test_make_collection.py
new file mode 100644
index 0000000..7105fcf
--- /dev/null
+++ b/tests/test_make_collection.py
@@ -0,0 +1,16 @@
+import unittest
+
+from iiif_prezi3 import Collection
+
+
+class MakeCollectionTest(unittest.TestCase):
+
+    def setUp(self):
+        self.parent_collection = Collection()
+
+    def test_make_collection(self):
+        child_collection = self.parent_collection.make_collection(
+            id='http://iiif.example.org/prezi/Manifest/0')
+        self.assertEqual(len(self.parent_collection.items), 1)
+        self.assertEqual(child_collection.id,
+                         'http://iiif.example.org/prezi/Manifest/0')
diff --git a/tests/test_make_manifest.py b/tests/test_make_manifest.py
new file mode 100644
index 0000000..1c180d2
--- /dev/null
+++ b/tests/test_make_manifest.py
@@ -0,0 +1,17 @@
+import unittest
+
+from iiif_prezi3 import Collection, Reference
+
+
+class MakeManifestTest(unittest.TestCase):
+
+    def setUp(self):
+        self.collection = Collection()
+
+    def test_make_manifest(self):
+        manifest = self.collection.make_manifest(
+            label={'en': ['default label']})
+        self.assertEqual(len(self.collection.items), 1)
+        self.assertIsInstance(self.collection.items[0], Reference)
+        self.assertEqual(manifest.label,
+                         {'en': ['default label']})