Skip to content

Commit

Permalink
Merge pull request #224 from markpbaggett/issue-191
Browse files Browse the repository at this point in the history
Attempt to address Issue-191.
  • Loading branch information
glenrobson authored Jan 15, 2025
2 parents e1663e5 + 655e706 commit 465fadb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
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)

0 comments on commit 465fadb

Please sign in to comment.