Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to address Issue-191. #224

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions iiif_prezi3/helpers/auto_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
8 changes: 4 additions & 4 deletions iiif_prezi3/helpers/make_manifest.py
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 14 additions & 2 deletions tests/test_make_manifest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from iiif_prezi3 import Collection, Reference
from iiif_prezi3 import Collection, HomepageItem, Reference, config


class MakeManifestTest(unittest.TestCase):
Expand All @@ -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)
Loading