diff --git a/iiif_prezi3/helpers/auto_fields.py b/iiif_prezi3/helpers/auto_fields.py index 5fbaf6e..58611ef 100644 --- a/iiif_prezi3/helpers/auto_fields.py +++ b/iiif_prezi3/helpers/auto_fields.py @@ -2,8 +2,8 @@ from ..config.config import Config, register_config from ..skeleton import (AnnotationPage, Canvas, Class, HomepageItem, - KeyValueString, NavPlace, ProviderItem, Range, - Reference, ResourceItem, ServiceItem1) + KeyValueString, ManifestRef, NavPlace, ProviderItem, + Range, Reference, ResourceItem, ServiceItem1) class AutoConfig(Config): @@ -179,8 +179,8 @@ def __init__(self): alst = AutoList(alstcfg, name="General") allst = AutoList(allstcfg, name="Language") # Set up some obvious defaults -ai.register_on_class(AnnotationPage, Class) -al.register_on_class(KeyValueString, Class, Reference, ResourceItem) +ai.register_on_class(AnnotationPage, Class, ManifestRef) +al.register_on_class(KeyValueString, Class, Reference, ResourceItem, ManifestRef) ait.register_on_class(Canvas, Range, AnnotationPage) alst.register_on_class(Class, AnnotationPage, ResourceItem, ServiceItem1, NavPlace, Reference, ProviderItem) allst.register_on_class(HomepageItem) diff --git a/iiif_prezi3/helpers/make_manifest.py b/iiif_prezi3/helpers/make_manifest.py index fe6db55..742e65e 100644 --- a/iiif_prezi3/helpers/make_manifest.py +++ b/iiif_prezi3/helpers/make_manifest.py @@ -1,19 +1,19 @@ from ..loader import monkeypatch_schema -from ..skeleton import Collection, Manifest +from ..skeleton import Collection, ManifestRef class MakeManifest: def make_manifest(self, **kwargs): - """Add a Manifest to a Collection. + """Add a Manifest to a Collection as a ManifestRef. 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) + manifest = ManifestRef(**kwargs) self.add_item(manifest) - return manifest + return manifest monkeypatch_schema(Collection, MakeManifest) diff --git a/tests/test_make_manifest.py b/tests/test_make_manifest.py index 1c180d2..712c8eb 100644 --- a/tests/test_make_manifest.py +++ b/tests/test_make_manifest.py @@ -1,6 +1,6 @@ import unittest -from iiif_prezi3 import Collection, Reference +from iiif_prezi3 import Collection, HomepageItem, Reference, config class MakeManifestTest(unittest.TestCase): @@ -9,9 +9,21 @@ def setUp(self): self.collection = Collection() def test_make_manifest(self): + config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en" + homepage = HomepageItem( + id="https://www.getty.edu/art/collection/object/103RQQ", + type="Text", + label="Home page at the Getty Museum Collection", + format="text/html", + language=["en"] + ) manifest = self.collection.make_manifest( - label={'en': ['default label']}) + id='http://example.org/iiif/1', + label='default label', + homepage=homepage, + ) self.assertEqual(len(self.collection.items), 1) self.assertIsInstance(self.collection.items[0], Reference) self.assertEqual(manifest.label, {'en': ['default label']}) + self.assertEqual(manifest.homepage, homepage)