diff --git a/MyCapytain/common/metadata.py b/MyCapytain/common/metadata.py index 5db3b235..51bf42f1 100644 --- a/MyCapytain/common/metadata.py +++ b/MyCapytain/common/metadata.py @@ -372,12 +372,12 @@ def keys(self): """ return self.__keys - def export(self, mime=Mimetypes.JSON): - if mime == Mimetypes.JSON: + def export(self, mime=Mimetypes.JSON.Std): + if mime == Mimetypes.JSON.Std: return { key: getattr(value, "__getstate__")() for key, value in self.metadata.items() } - elif mime == Mimetypes.JSON_DTS: + elif mime == Mimetypes.JSON.DTS: descs = { } @@ -397,7 +397,7 @@ def export(self, mime=Mimetypes.JSON): descs[lang][ns+k] = value return [value for value in descs.values()] - elif mime == Mimetypes.RDFXML: + elif mime == Mimetypes.XML.RDF: out = "" for key in sorted(self.metadata.keys()): metadatum = self.metadata[key] diff --git a/MyCapytain/common/utils.py b/MyCapytain/common/utils.py index eb924a01..da9fc947 100644 --- a/MyCapytain/common/utils.py +++ b/MyCapytain/common/utils.py @@ -376,14 +376,22 @@ class Mimetypes: :cvar MY_CAPYTAIN: MyCapytain Object Resource (Native Python CapiTainS Object) """ - JSON = "application/text" - JSON_CTS = "application/ld+json:CTS" - JSON_DTS = "application/ld+json:DTS" - XML = "text/xml" - RDFXML = "application/rdf+xml" - CTS_XML = "text/xml:CTS" - MY_CAPYTAIN = "MyCapytain" - ETREE = "python/lxml" - MyCapytainText = "MyCapytain/Text" - PLAINTEXT = "text/plain" - NestedDict = "python/NestedDict" \ No newline at end of file + + class JSON: + Std = "application/text" + CTS = "application/ld+json:CTS" + DTS = "application/ld+json:DTS" + + class XML: + Std = "text/xml" + RDF = "application/rdf+xml" + CTS = "text/xml:CTS" + + class PYTHON: + NestedDict = "python/NestedDict" + ETREE = "python/lxml" + + class MyCapytain: + ReadableText = "Capitains/ReadableText" + + PLAINTEXT = "text/plain" \ No newline at end of file diff --git a/MyCapytain/resources/collections/cts.py b/MyCapytain/resources/collections/cts.py index d20811b0..7b8396e5 100644 --- a/MyCapytain/resources/collections/cts.py +++ b/MyCapytain/resources/collections/cts.py @@ -204,7 +204,7 @@ def __str__(self): strings.append("".format(tag_end)) return "".join(strings) - def export(self, output=Mimetypes.ETREE, domain="", **kwargs): + def export(self, output=Mimetypes.PYTHON.ETREE, domain="", **kwargs): """ Create a {format} version of the Work :param output: Format to be chosen (Only XML for now) @@ -214,9 +214,9 @@ def export(self, output=Mimetypes.ETREE, domain="", **kwargs): :rtype: lxml.etree._Element :returns: XML representation of the object """ - if output == Mimetypes.ETREE: + if output == Mimetypes.PYTHON.ETREE: return xmlparser(str(self)) - elif output == Mimetypes.MyCapytainText: + elif output == Mimetypes.PYTHON.MyCapytain.ReadableText: complete_metadata = self.metadata for parent in self.parents: if isinstance(parent, cts.CTSCollection) and hasattr(parent, "metadata"): @@ -274,6 +274,17 @@ def parse(self, resource): return None + @property + def readable(self): + """ Readable property should return elements where the element can be queried for getPassage / getReffs + """ + return True + + @property + def descendants(self): + return [] + + def Edition(resource=None, urn=None, parents=None): """ Create an edition subtyped Text object @@ -333,7 +344,7 @@ def __str__(self): strings.append("") return "".join(strings) - def export(self, output=Mimetypes.ETREE, domain=""): + def export(self, output=Mimetypes.PYTHON.ETREE, domain=""): """ Create a {format} version of the Work :param output: Format to be chosen (Only XML for now) @@ -343,7 +354,7 @@ def export(self, output=Mimetypes.ETREE, domain=""): :rtype: lxml.etree._Element :returns: XML representation of the object """ - if output == Mimetypes.ETREE: + if output == Mimetypes.PYTHON.ETREE: return xmlparser(str(self)) return self.default_export(output, domain) @@ -420,7 +431,7 @@ def __str__(self): strings.append("") return "".join(strings) - def export(self, output=Mimetypes.ETREE, domain=""): + def export(self, output=Mimetypes.PYTHON.ETREE, domain=""): """ Create a {format} version of the Work :param output: Format to be chosen (Only XML for now) @@ -430,7 +441,7 @@ def export(self, output=Mimetypes.ETREE, domain=""): :rtype: lxml.etree._Element :returns: XML representation of the object """ - if output == Mimetypes.ETREE: + if output == Mimetypes.PYTHON.ETREE: return xmlparser(str(self)) return self.default_export(output, domain) @@ -466,7 +477,7 @@ class TextInventory(cts.TextInventory): .. automethod:: __str__ """ - def export(self, output=Mimetypes.ETREE, domain=""): + def export(self, output=Mimetypes.PYTHON.ETREE, domain=""): """ Create a {format} version of the Work :param output: Format to be chosen (Only XML for now) @@ -476,7 +487,7 @@ def export(self, output=Mimetypes.ETREE, domain=""): :rtype: lxml.etree._Element :returns: XML representation of the object """ - if output == Mimetypes.ETREE: + if output == Mimetypes.PYTHON.ETREE: return xmlparser(str(self)) return self.default_export(output, domain) @@ -500,7 +511,7 @@ def __str__(self): strings.append("") return "".join(strings) - def export(self, output=Mimetypes.ETREE, domain=""): + def export(self, output=Mimetypes.PYTHON.ETREE, domain=""): """ Create a {format} version of the Work :param output: Format to be chosen (Only XML for now) @@ -510,7 +521,7 @@ def export(self, output=Mimetypes.ETREE, domain=""): :rtype: lxml.etree._Element :returns: XML representation of the object """ - if output == Mimetypes.ETREE: + if output == Mimetypes.PYTHON.ETREE: return xmlparser(str(self)) return self.default_export(output, domain) diff --git a/MyCapytain/resources/prototypes/cts/inventory.py b/MyCapytain/resources/prototypes/cts/inventory.py index 04808069..36c3a157 100644 --- a/MyCapytain/resources/prototypes/cts/inventory.py +++ b/MyCapytain/resources/prototypes/cts/inventory.py @@ -179,6 +179,18 @@ def __init__(self, resource=None, urn=None, parents=None, subtype="Edition"): if resource is not None: self.setResource(resource) + @property + def readable(self): + return True + + @property + def members(self): + return [] + + @property + def descendants(self): + return [] + def translations(self, key=None): """ Get translations in given language @@ -243,6 +255,10 @@ def __init__(self, resource=None, urn=None, parents=None): if resource is not None: self.setResource(resource) + @property + def readable(self): + return True + def update(self, other): """ Merge two Work Objects. @@ -293,7 +309,7 @@ def __len__(self): @property def members(self): - return self.texts.values() + return list(self.texts.values()) class TextGroup(CTSCollection): @@ -313,7 +329,7 @@ class TextGroup(CTSCollection): @property def members(self): - return self.works.values() + return list(self.works.values()) def __init__(self, resource=None, urn=None, parents=None): super(TextGroup, self).__init__() @@ -384,7 +400,7 @@ class TextInventory(CTSCollection): @property def members(self): - return self.textgroups.values() + return list(self.textgroups.values()) def __init__(self, resource=None, name=None): super(TextInventory, self).__init__() diff --git a/MyCapytain/resources/prototypes/metadata.py b/MyCapytain/resources/prototypes/metadata.py index fb4b63da..b2fb5643 100644 --- a/MyCapytain/resources/prototypes/metadata.py +++ b/MyCapytain/resources/prototypes/metadata.py @@ -45,6 +45,12 @@ def id(self): """ return self.__id__ + @property + def readable(self): + """ Readable property should return elements where the element can be queried for getPassage / getReffs + """ + return False + @id.setter def id(self, value): self.__id__ = value @@ -57,7 +63,24 @@ def members(self): """ return [] - def default_export(self, output=Mimetypes.JSON_DTS, domain=""): + @property + def descendants(self): + """ Any descendant (no max level) of the collection's item + + :rtype: [Collection] + """ + return self.members + \ + [submember for member in self.members for submember in member.descendants] + + @property + def readableDescendants(self): + """ List of element available which are readable + + :rtype: [Collection] + """ + return [member for member in self.descendants if member.readable] + + def default_export(self, output=Mimetypes.JSON.DTS, domain=""): """ Export the collection item in the Mimetype required :param output: Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes) @@ -66,19 +89,19 @@ def default_export(self, output=Mimetypes.JSON_DTS, domain=""): :type domain: str :return: Object using a different representation """ - if output == Mimetypes.JSON_DTS: + if output == Mimetypes.JSON.DTS: if self.title: m = self.metadata + self.title else: m = self.metadata o = { "@id": domain+self.id, - RDF_PREFIX["dts"] + "description": m.export(Mimetypes.JSON_DTS), + RDF_PREFIX["dts"] + "description": m.export(Mimetypes.JSON.DTS), RDF_PREFIX["dts"] + "properties" : self.properties } if len(self.members): o[RDF_PREFIX["dts"] + "members"] = [ - member.export(Mimetypes.JSON_DTS, domain) for member in self.members + member.export(Mimetypes.JSON.DTS, domain) for member in self.members ] return o diff --git a/MyCapytain/resources/prototypes/text.py b/MyCapytain/resources/prototypes/text.py index 0c0bf99d..74685ecb 100644 --- a/MyCapytain/resources/prototypes/text.py +++ b/MyCapytain/resources/prototypes/text.py @@ -81,7 +81,7 @@ def metadata(self, value): else: raise TypeError(".metadata should be an instance of Metadata") - def default_export(self, output=Mimetypes.JSON_DTS, exclude=None): + def default_export(self, output=Mimetypes.JSON.DTS, exclude=None): """ Export the textual node item in the Mimetype required :param output: Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes) diff --git a/MyCapytain/resources/texts/api/cts.py b/MyCapytain/resources/texts/api/cts.py index dcd8763a..90932e5e 100644 --- a/MyCapytain/resources/texts/api/cts.py +++ b/MyCapytain/resources/texts/api/cts.py @@ -126,7 +126,9 @@ def getPassagePlus(self, reference=None): response = xmlparser(self.retriever.getPassagePlus(urn=urn)) self.__parse_request__(response.xpath("//ti:reply/ti:label", namespaces=NS)[0]) - return Passage(urn=urn, resource=response, retriever=self.retriever) + passage = Passage(urn=urn, resource=response, retriever=self.retriever) + passage.metadata, passage.citation = self.metadata, self.citation + return passage def __parse_request__(self, xml): """ Parse a request with metadata information diff --git a/MyCapytain/resources/texts/encodings.py b/MyCapytain/resources/texts/encodings.py index f11931fe..7477b7dc 100644 --- a/MyCapytain/resources/texts/encodings.py +++ b/MyCapytain/resources/texts/encodings.py @@ -29,7 +29,7 @@ def __str__(self): :rtype: basestring :returns: XML of the passage in string form """ - return self.export(output=Mimetypes.XML) + return self.export(output=Mimetypes.XML.Std) def export(self, output=Mimetypes.PLAINTEXT, exclude=None, _preformatted=False): """ Text content of the passage @@ -63,20 +63,20 @@ def export(self, output=Mimetypes.PLAINTEXT, exclude=None, _preformatted=False): elif _preformatted is False: exclude = "" - if output == Mimetypes.ETREE: + if output == Mimetypes.PYTHON.ETREE: """ Exports the whole resource as a LXML object """ return self.resource - elif output == Mimetypes.XML: + elif output == Mimetypes.XML.Std: """ Exports the whole resource formatted as XML but as string object """ return tostring(self.resource, encoding=str) - elif output == Mimetypes.NestedDict: + elif output == Mimetypes.PYTHON.NestedDict: """ Exports the whole resource into a NestedDict """ - reffs = self.getValidReff(level=len(self.citation)) + reffs = self.getReffs(level=len(self.citation)) text = nested_ordered_dictionary() for reff in reffs: _r = reff.split(".") diff --git a/tests/common/test_metadata.py b/tests/common/test_metadata.py index 18157741..c7d65310 100644 --- a/tests/common/test_metadata.py +++ b/tests/common/test_metadata.py @@ -220,7 +220,7 @@ def test_export_json(self): six.assertCountEqual( self, - b.export(Mimetypes.JSON), + b.export(Mimetypes.JSON.Std), {'dc:editor': {'default': 'eng', 'langs': [('eng', 'Captain Hook'), ('fre', 'Capitaine Crochet')], 'name': 'dc:editor'}, 'title': {'default': 'eng', 'langs': [('eng', 'ttl'), ('fre', 'titre')], 'name': 'title'}, @@ -237,7 +237,7 @@ def test_export_jsonld(self): six.assertCountEqual( self, - b.export(Mimetypes.JSON_DTS), + b.export(Mimetypes.JSON.DTS), [ { 'http://chs.harvard.edu/xmlns/cts/desc': 'Omelette', @@ -261,7 +261,7 @@ def test_export_xmlRDF(self): m5 = Metadatum("dc:editor", [("eng", "Captain Hook"), ("fre", "Capitaine Crochet")]) b[("desc", "title", "dc:editor")] = (m3, m4, m5) self.assertEqual( - b.export(Mimetypes.RDFXML), + b.export(Mimetypes.XML.RDF), """ Captain HookCapitaine CrochetOmelettettltitre diff --git a/tests/resolvers/cts/test_api.py b/tests/resolvers/cts/test_api.py index a053d0c8..73b9c73c 100644 --- a/tests/resolvers/cts/test_api.py +++ b/tests/resolvers/cts/test_api.py @@ -1,7 +1,10 @@ from MyCapytain.resolvers.cts.api import HttpCTSResolver from MyCapytain.retrievers.cts5 import CTS from MyCapytain.common.utils import xmlparser, Mimetypes, NS +from MyCapytain.common.metadata import Metadatum from MyCapytain.resources.prototypes.text import Passage +from MyCapytain.resources.collections.cts import TextInventory, TextGroup, Work, Text +from MyCapytain.resources.prototypes.metadata import Collection from unittest import TestCase from mock import MagicMock @@ -59,7 +62,7 @@ def test_getPassage_full(self): ) self.assertEqual( - passage.export(output=Mimetypes.ETREE).xpath(".//tei:l[@n='1']/text()", namespaces=NS, magic_string=False), + passage.export(output=Mimetypes.PYTHON.ETREE).xpath(".//tei:l[@n='1']/text()", namespaces=NS, magic_string=False), ["Hic est quem legis ille, quem requiris, "], "Export to Etree should give an Etree or Etree like object" ) @@ -95,8 +98,230 @@ def test_getPassage_subreference(self): ) self.assertEqual( - passage.export(output=Mimetypes.ETREE).xpath(".//tei:l[@n='1']/text()", namespaces=NS, magic_string=False), + passage.export(output=Mimetypes.PYTHON.ETREE).xpath(".//tei:l[@n='1']/text()", namespaces=NS, magic_string=False), ["Hic est quem legis ille, quem requiris, "], "Export to Etree should give an Etree or Etree like object" ) + def test_getPassage_full_metadata(self): + """ Test that we can get a full text with its metadata""" + passage = self.resolver.getPassage("urn:cts:latinLit:phi1294.phi002.perseus-lat2", metadata=True) + + # We check we made a reroute to GetPassage request + self.resolver.endpoint.getPassagePlus.assert_called_with( + urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2" + ) + self.assertIsInstance( + passage, Passage, + "GetPassage should always return passages objects" + ) + self.assertIsInstance( + passage.about.metadata["title"], Metadatum + ) + self.assertEqual( + passage.metadata["title"]["eng"], "Epigrammata", + "CTS API Remote HTTP Response should be correctly parsed" + ) + self.assertEqual( + passage.metadata["groupname"]["eng"], "Martial", + "CTS API Remote HTTP Response should be correctly parsed" + ) + self.assertEqual( + passage.metadata["label"]["eng"], "M. Valerii Martialis Epigrammaton libri / recognovit W. Heraeus", + "CTS API Remote HTTP Response should be correctly parsed" + ) + self.assertEqual( + passage.citation.name, "book", + "CTS API Remote HTTP Response should be correctly parsed" + ) + self.assertEqual( + len(passage.citation), 3, + "CTS API Remote HTTP Response should be correctly parsed" + ) + + children = list(passage.getReffs()) + + # We check the passage is able to perform further requests and is well instantiated + self.resolver.endpoint.getValidReff.assert_called_with( + urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2", + level=1 + ) + self.assertEqual( + children[0], 'urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1.1', + "Resource should be string identifiers" + ) + + self.assertIn( + "Hic est quem legis ille, quem requiris,", passage.export(output=Mimetypes.PLAINTEXT), + "Export Text should work correctly" + ) + + self.assertEqual( + passage.export(output=Mimetypes.PYTHON.ETREE).xpath(".//tei:l[@n='1']/text()", namespaces=NS, magic_string=False), + ["Hic est quem legis ille, quem requiris, "], + "Export to Etree should give an Etree or Etree like object" + ) + + def test_getPassage_prevnext(self): + """ Test that we can get a full text with its metadata""" + passage = self.resolver.getPassage("urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1", metadata=True) + + # We check we made a reroute to GetPassage request + self.resolver.endpoint.getPassagePlus.assert_called_with( + urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1" + ) + self.assertIsInstance( + passage, Passage, + "GetPassage should always return passages objects" + ) + self.assertEqual( + passage.prevId, "urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.pr", + "Previous Passage ID should be parsed" + ) + self.assertEqual( + passage.nextId, "urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.2", + "Next Passage ID should be parsed" + ) + children = list(passage.getReffs()) + + _ = passage.next + self.resolver.endpoint.getPassage.assert_called_with( + urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.2" + ) + _ = passage.prev + self.resolver.endpoint.getPassage.assert_called_with( + urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.pr" + ) + + # We check the passage is able to perform further requests and is well instantiated + self.resolver.endpoint.getValidReff.assert_called_with( + urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1", + level=1 + ) + self.assertEqual( + children[0], 'urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1.1', + "Resource should be string identifiers" + ) + + self.assertIn( + "Hic est quem legis ille, quem requiris,", passage.export(output=Mimetypes.PLAINTEXT), + "Export Text should work correctly" + ) + + self.assertEqual( + passage.export(output=Mimetypes.PYTHON.ETREE).xpath(".//tei:l[@n='1']/text()", namespaces=NS, magic_string=False), + ["Hic est quem legis ille, quem requiris, "], + "Export to Etree should give an Etree or Etree like object" + ) + + def test_getPassage_metadata_prevnext(self): + """ Test that we can get a full text with its metadata""" + passage = self.resolver.getPassage("urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1", metadata=True, prevnext=True) + + # We check we made a reroute to GetPassage request + self.resolver.endpoint.getPassagePlus.assert_called_with( + urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1" + ) + self.assertIsInstance( + passage, Passage, + "GetPassage should always return passages objects" + ) + self.assertIsInstance( + passage.about.metadata["title"], Metadatum + ) + self.assertEqual( + passage.metadata["title"]["eng"], "Epigrammata", + "CTS API Remote HTTP Response should be correctly parsed" + ) + self.assertEqual( + passage.metadata["groupname"]["eng"], "Martial", + "CTS API Remote HTTP Response should be correctly parsed" + ) + self.assertEqual( + passage.metadata["label"]["eng"], "M. Valerii Martialis Epigrammaton libri / recognovit W. Heraeus", + "CTS API Remote HTTP Response should be correctly parsed" + ) + self.assertEqual( + passage.citation.name, "book", + "CTS API Remote HTTP Response should be correctly parsed" + ) + self.assertEqual( + len(passage.citation), 3, + "CTS API Remote HTTP Response should be correctly parsed" + ) + self.assertEqual( + passage.prevId, "urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.pr", + "Previous Passage ID should be parsed" + ) + self.assertEqual( + passage.nextId, "urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.2", + "Next Passage ID should be parsed" + ) + children = list(passage.getReffs()) + + _ = passage.next + self.resolver.endpoint.getPassage.assert_called_with( + urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.2" + ) + _ = passage.prev + self.resolver.endpoint.getPassage.assert_called_with( + urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.pr" + ) + + # We check the passage is able to perform further requests and is well instantiated + self.resolver.endpoint.getValidReff.assert_called_with( + urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1", + level=1 + ) + self.assertEqual( + children[0], 'urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1.1', + "Resource should be string identifiers" + ) + + self.assertIn( + "Hic est quem legis ille, quem requiris,", passage.export(output=Mimetypes.PLAINTEXT), + "Export Text should work correctly" + ) + + self.assertEqual( + passage.export(output=Mimetypes.PYTHON.ETREE).xpath(".//tei:l[@n='1']/text()", namespaces=NS, magic_string=False), + ["Hic est quem legis ille, quem requiris, "], + "Export to Etree should give an Etree or Etree like object" + ) + + def test_getMetadata_full(self): + """ Checks retrieval of Metadata information """ + metadata = self.resolver.getMetadata() + self.resolver.endpoint.getCapabilities.assert_called_with() + self.assertIsInstance( + metadata, Collection, + "Resolver should return a collection object" + ) + self.assertIsInstance( + metadata.members[0], TextGroup, + "Members of Inventory should be TextGroups" + ) + self.assertEqual( + len(metadata.descendants), 32, + "There should be as many descendants as there is edition, translation, works and textgroup" + ) + self.assertEqual( + len(metadata.readableDescendants), 28, + "There should be as many readable descendants as there is edition, translation, works" + ) + self.assertEqual( + len([x for x in metadata.readableDescendants if isinstance(x, Text)]), 15, + "There should be 14 editions + 1 translations in readableDescendants" + ) + self.assertEqual( + len(metadata.export( + output=Mimetypes.PYTHON.ETREE + ).xpath("//ti:edition[@urn='urn:cts:latinLit:phi1294.phi002.perseus-lat2']", namespaces=NS)), 1, + "There should be one node in exported format corresponding to lat2" + ) + self.assertEqual( + len(metadata.export( + output=Mimetypes.PYTHON.ETREE + ).xpath("//ti:edition[@urn='urn:cts:latinLit:phi1294.phi002.perseus-lat2']", namespaces=NS)), 1, + "There should be one node in exported format corresponding to lat2" + ) diff --git a/tests/resources/commonTests.py b/tests/resources/commonTests.py index e3c3fa4b..5ca64166 100644 --- a/tests/resources/commonTests.py +++ b/tests/resources/commonTests.py @@ -161,7 +161,7 @@ def testValidReffs(self): def test_nested_dict(self): """ Check the nested dict export of a local.Text object """ - nested = self.TEI.export(output=Mimetypes.NestedDict, exclude=["tei:note"]) + nested = self.TEI.export(output=Mimetypes.PYTHON.NestedDict, exclude=["tei:note"]) self.assertEqual(nested["1"]["3"]["8"], "Ibis ab excusso missus in astra sago. ", "Check that notes are removed ") self.assertEqual(nested["1"]["pr"]["1"], "Spero me secutum in libellis meis tale temperamen-", @@ -426,12 +426,11 @@ def test_Text_text_function(self): def test_get_passage_hyper_context_double_slash_xpath(self): simple = self.seneca.getPassage(Reference("1-10")) str_simple = simple.export( - output=Mimetypes.XML + output=Mimetypes.XML.Std ) text = Text( resource=str_simple, citation=self.seneca.citation - ) self.assertEqual( text.getPassage(Reference("1"), simple=True).export( diff --git a/tests/resources/test_inventory.py b/tests/resources/test_inventory.py index 53b7bfd7..87e32d9f 100644 --- a/tests/resources/test_inventory.py +++ b/tests/resources/test_inventory.py @@ -343,7 +343,7 @@ def test_export_to_text(self): TI = TextInventory(resource=self.getCapabilities, name="annotsrc") ti_text = TI["urn:cts:latinLit:phi1294.phi002.perseus-lat2"] - txt_text = ti_text.export(output=Mimetypes.MyCapytainText) + txt_text = ti_text.export(output=Mimetypes.PYTHON.MyCapytain.ReadableText) self.assertEqual(str(txt_text.urn), "urn:cts:latinLit:phi1294.phi002.perseus-lat2") self.assertEqual(txt_text.metadata["groupname"]["eng"], "Martial") # Check inheritance of textgroup metadata self.assertEqual(txt_text.metadata["title"]["eng"], "Epigrammata") # Check inheritance of work metadata @@ -617,7 +617,7 @@ def test_export_jsonld(self): } ] }, - tg.export(Mimetypes.JSON_DTS, domain="http://capitain.github.io/domain/"), + tg.export(Mimetypes.JSON.DTS, domain="http://capitain.github.io/domain/"), "JSON DTS export should be stable" ) diff --git a/tests/testing_data/cts/getpassageplus.xml b/tests/testing_data/cts/getpassageplus.xml index c04b6a63..d292d6e7 100644 --- a/tests/testing_data/cts/getpassageplus.xml +++ b/tests/testing_data/cts/getpassageplus.xml @@ -14,9 +14,7 @@ Martial Epigrammata urn:cts:latinLit:phi1294.phi002 - - M. Valerii Martialis Epigrammaton libri / recognovit W. Heraeus - + M. Valerii Martialis Epigrammaton libri / recognovit W. Heraeus