From 66c1b94e42129d290166d28406816ac1c4a8ee7c Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Thu, 9 Jan 2025 14:06:50 -0600 Subject: [PATCH 1/2] Attempt to address Issue-191. --- iiif_prezi3/helpers/make_manifest.py | 8 ++++---- tests/test_make_manifest.py | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) 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..cc9f791 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, Reference, HomepageItem, 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[0], homepage) From 655e706e628d6b124bce7361f4c32a74ebb5597c Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Thu, 9 Jan 2025 17:08:36 -0600 Subject: [PATCH 2/2] Fix test and autohelpers. --- iiif_prezi3/helpers/auto_fields.py | 8 ++++---- tests/test_make_manifest.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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/tests/test_make_manifest.py b/tests/test_make_manifest.py index cc9f791..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, HomepageItem, config +from iiif_prezi3 import Collection, HomepageItem, Reference, config class MakeManifestTest(unittest.TestCase): @@ -26,4 +26,4 @@ def test_make_manifest(self): self.assertIsInstance(self.collection.items[0], Reference) self.assertEqual(manifest.label, {'en': ['default label']}) - self.assertEqual(manifest.homepage[0], homepage) + self.assertEqual(manifest.homepage, homepage)