diff --git a/MyCapytain/common/reference/_dts_1.py b/MyCapytain/common/reference/_dts_1.py index 77214864..60743134 100644 --- a/MyCapytain/common/reference/_dts_1.py +++ b/MyCapytain/common/reference/_dts_1.py @@ -100,7 +100,8 @@ def match(self, passageId): class DtsCitationSet(BaseCitationSet): - """ Set of citation that are supposed + """ Set of citations following the DTS model (Unlike CTS, one citation + can have two or more children) """ diff --git a/MyCapytain/errors.py b/MyCapytain/errors.py index 7c6fd551..7eedc8f5 100644 --- a/MyCapytain/errors.py +++ b/MyCapytain/errors.py @@ -15,7 +15,10 @@ class MyCapytainException(BaseException): class JsonLdCollectionMissing(MyCapytainException): - """ Error thrown when a JSON LD has now first ressource + """ Error thrown when a JSON LD has now first resource + + Raised when a json supposed to contain collection is parsed + but nothing is found """ @@ -68,7 +71,7 @@ class UnknownCollection(KeyError, MyCapytainException): class EmptyReference(SyntaxWarning, MyCapytainException): - """ Error generated when a CtsReference is wrong + """ Error generated when a CtsReference does not exist or is invalid """ diff --git a/MyCapytain/resolvers/cts/local.py b/MyCapytain/resolvers/cts/local.py index 9a5296d8..0b224288 100644 --- a/MyCapytain/resolvers/cts/local.py +++ b/MyCapytain/resolvers/cts/local.py @@ -286,14 +286,14 @@ def parse(self, resource): for folder in resource: cts_files = glob("{base_folder}/data/*/__cts__.xml".format(base_folder=folder)) for cts_file in cts_files: - textgroup, cts_file = self._parse_textgroup(cts_file) + textgroup, cts_file = self._parse_textgroup_wrapper(cts_file) textgroups.append((textgroup, cts_file)) for textgroup, cts_textgroup_file in textgroups: cts_work_files = glob("{parent}/*/__cts__.xml".format(parent=os.path.dirname(cts_textgroup_file))) for cts_work_file in cts_work_files: - _, parsed_texts, directory = self._parse_work(cts_work_file, textgroup) + _, parsed_texts, directory = self._parse_work_wrapper(cts_work_file, textgroup) texts.extend([(text, directory) for text in parsed_texts]) for text, directory in texts: diff --git a/MyCapytain/resolvers/dts/api_v1.py b/MyCapytain/resolvers/dts/api_v1.py index e405863a..1defc8a5 100644 --- a/MyCapytain/resolvers/dts/api_v1.py +++ b/MyCapytain/resolvers/dts/api_v1.py @@ -70,6 +70,7 @@ def endpoint(self) -> HttpDtsRetriever: return self._endpoint def getMetadata(self, objectId: str=None, **filters) -> HttpResolverDtsCollection: + """ Retrieves metadata calling the Collections Endpoint """ req = self.endpoint.get_collection(objectId) req.raise_for_status() @@ -87,6 +88,7 @@ def getReffs( include_descendants: bool=False, additional_parameters: Optional[Dict[str, Any]]=None ) -> DtsReferenceSet: + """ Retrieve references by calling the Navigation API """ if not additional_parameters: additional_parameters = {} @@ -151,7 +153,7 @@ def getTextualNode( prevnext: bool=False, metadata: bool=False ) -> DtsResolverDocument: - """ Retrieve a text node from the API + """ Retrieve a text node from the API via the Document Endpoint :param textId: CtsTextMetadata Identifier :type textId: str diff --git a/MyCapytain/resources/collections/cts.py b/MyCapytain/resources/collections/cts.py index 67bcc95b..d4092182 100644 --- a/MyCapytain/resources/collections/cts.py +++ b/MyCapytain/resources/collections/cts.py @@ -257,10 +257,8 @@ def parse(cls, resource, parent=None, _with_children=False): """ Parse a resource :param resource: Element rerpresenting a work - :param type: basestring, etree._Element :param parent: Parent of the object :type parent: XmlCtsTextgroupMetadata - :param _cls_dict: Dictionary of classes to generate subclasses """ xml = xmlparser(resource) o = cls(urn=xml.get("urn"), parent=parent) @@ -307,7 +305,6 @@ def parse(cls, resource, parent=None): :param resource: Element representing the textgroup :param parent: Parent of the textgroup - :param _cls_dict: Dictionary of classes to generate subclasses """ xml = xmlparser(resource) o = cls(urn=xml.get("urn"), parent=parent) @@ -334,7 +331,6 @@ def parse(cls, resource): """ Parse a resource :param resource: Element representing the text inventory - :param _cls_dict: Dictionary of classes to generate subclasses """ xml = xmlparser(resource) o = cls(name=xml.xpath("//ti:TextInventory", namespaces=XPATH_NAMESPACES)[0].get("tiid") or "") diff --git a/MyCapytain/resources/prototypes/cts/text.py b/MyCapytain/resources/prototypes/cts/text.py index 7eefedc2..0584a19f 100644 --- a/MyCapytain/resources/prototypes/cts/text.py +++ b/MyCapytain/resources/prototypes/cts/text.py @@ -95,7 +95,7 @@ def set_metadata_from_collection(self, text_metadata: CtsTextMetadata): """ Set the object metadata using its collections recursively :param text_metadata: Object representing the current text as a collection - :type text_metadata: CtsEditionMetadata or CtsTranslationMetadata + :type text_metadata: CtsTextMetadata """ edition, work, textgroup = tuple(([text_metadata] + text_metadata.parents)[:3]) diff --git a/MyCapytain/retrievers/dts/__init__.py b/MyCapytain/retrievers/dts/__init__.py index f3de2995..cf833bfb 100644 --- a/MyCapytain/retrievers/dts/__init__.py +++ b/MyCapytain/retrievers/dts/__init__.py @@ -158,7 +158,7 @@ def get_navigation( def get_document( self, collection_id, ref=None, mimetype="application/tei+xml, application/xml"): - """ Make a navigation request on the DTS API + """ Make a document request on the DTS API :param collection_id: Id of the collection :param ref: If ref is a tuple, it is treated as a range. String or int are treated as single ref diff --git a/tests/common/test_reference/test_citation_dts.py b/tests/common/test_reference/test_citation_dts.py index e2083bce..169d874d 100644 --- a/tests/common/test_reference/test_citation_dts.py +++ b/tests/common/test_reference/test_citation_dts.py @@ -112,14 +112,14 @@ def test_ingest_simple_line(self): cite = DtsCitationSet.ingest(_context(_ex_2)) children = {c.name: c for c in cite} - self.assertEqual(2, cite.depth, "There should be 3 levels of citation") - self.assertEqual(2, len(cite), "There should be 5 children") + self.assertEqual(2, cite.depth, "There should be 2 levels of citation") + self.assertEqual(2, len(cite), "There should be 2 children") self.assertEqual(list(cite[-1]), [children["line"]], "Last level should contain line only") self.assertEqual(list(cite[-1]), list(cite[1]), "-1 level == level 1") self.assertCountEqual(list(cite[-2]), [children["poem"]], "-2 level == level 0") - self.assertCountEqual(list(cite[-2]), list(cite[0]), "-32 level == level 0") + self.assertCountEqual(list(cite[-2]), list(cite[0]), "-2 level == level 0") self.assertIsInstance(cite, DtsCitationSet, "Root should be a DtsCitationSet") self.assertEqual([type(child) for child in cite.children], [DtsCitation], "Children should be DtsCitation") diff --git a/tests/resolvers/cts/test_local.py b/tests/resolvers/cts/test_local.py index 0e674b9c..e6f22212 100644 --- a/tests/resolvers/cts/test_local.py +++ b/tests/resolvers/cts/test_local.py @@ -544,11 +544,11 @@ def test_getSiblings(self): ) self.assertEqual( previous, CtsReference("1.pr"), - "Previous should be well computed" + "Previous reference should be well computed" ) self.assertEqual( nextious, CtsReference("1.2"), - "Previous should be well computed" + "Next reference should be well computed" ) def test_getSiblings_nextOnly(self): @@ -558,11 +558,11 @@ def test_getSiblings_nextOnly(self): ) self.assertEqual( previous, None, - "Previous Should not exist" + "Previous reference should not exist" ) self.assertEqual( nextious, CtsReference("1.1"), - "Next should be well computed" + "Next reference should be well computed" ) def test_getSiblings_prevOnly(self): @@ -572,11 +572,11 @@ def test_getSiblings_prevOnly(self): ) self.assertEqual( previous, CtsReference("14.222"), - "Previous should be well computed" + "Previous reference should be well computed" ) self.assertEqual( nextious, None, - "Next should not exist" + "Next reference should not exist" ) def test_getReffs_full(self): diff --git a/tests/resolvers/dts/api_v1/data/collection/readableDescendants/coll1_1_1.json b/tests/resolvers/dts/api_v1/data/collection/readableDescendants/coll1_1_1.json index 6d6a95be..1a084e88 100644 --- a/tests/resolvers/dts/api_v1/data/collection/readableDescendants/coll1_1_1.json +++ b/tests/resolvers/dts/api_v1/data/collection/readableDescendants/coll1_1_1.json @@ -7,5 +7,5 @@ "@id": "/coll1_1_1", "@type": "Resource", "totalItems": 0, - "title": "Collection 1.2.1" + "title": "Collection 1.1.1" } \ No newline at end of file diff --git a/tests/resolvers/dts/api_v1/test_metadata.py b/tests/resolvers/dts/api_v1/test_metadata.py index 34cab98b..cc3aa107 100644 --- a/tests/resolvers/dts/api_v1/test_metadata.py +++ b/tests/resolvers/dts/api_v1/test_metadata.py @@ -254,7 +254,7 @@ def add_mock(mocks, id_): "Collections should be retrieved automatically" ) history = [history.url for history in mock_set.request_history] - print(history) + self.assertNotIn( self.root_uri+"/collections?id=%2Fcoll1_2_2_1", history,