Пример #1
0
    def test_getpassageplus(self, requests):
        text = CtsText("urn:cts:latinLit:phi1294.phi002.perseus-lat2",
                       self.endpoint)
        requests.return_value.text = GET_PASSAGE_PLUS

        # Test with -1
        passage = text.getPassagePlus(reference="1.1")
        requests.assert_called_with(
            "http://services.perseids.org/remote/cts",
            params={
                "request": "GetPassagePlus",
                "urn": "urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1"
            })

        self.assertIsInstance(passage, CtsPassage)
        self.assertEqual(str(passage.urn),
                         "urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1")
        self.assertEqual(
            passage.xml.findall(".//{http://www.tei-c.org/ns/1.0}l[@n='1']")
            [0].text, "Hic est quem legis ille, quem requiris, ")
        self.assertEqual(text.citation.name, "book")
        self.assertEqual(len(text.citation), 3)

        # Test without reference
        text.getPassagePlus()
        requests.assert_called_with(
            "http://services.perseids.org/remote/cts",
            params={
                "request": "GetPassagePlus",
                "urn": "urn:cts:latinLit:phi1294.phi002.perseus-lat2"
            })
Пример #2
0
    def getTextualNode(self,
                       textId,
                       subreference=None,
                       prevnext=False,
                       metadata=False):
        """ Retrieve a text node from the API

        :param textId: CtsTextMetadata Identifier
        :type textId: str
        :param subreference: CapitainsCtsPassage Reference
        :type subreference: str
        :param prevnext: Retrieve graph representing previous and next passage
        :type prevnext: boolean
        :param metadata: Retrieve metadata about the passage and the text
        :type metadata: boolean
        :return: CapitainsCtsPassage
        :rtype: CapitainsCtsPassage
        """
        text = CtsText(urn=textId, retriever=self.endpoint)
        if metadata or prevnext:
            return text.getPassagePlus(reference=subreference)
        else:
            return text.getTextualNode(subreference=subreference)