class NemoResource(unittest.TestCase):
    """ Test Suite for Nemo
    """
    endpoint = HttpCTSResolver(CTS("http://website.com/cts/api"))
    body_xsl = "tests/test_data/xsl_test.xml"

    def setUp(self):
        with open("tests/test_data/getcapabilities.xml", "r") as f:
            self.getCapabilities = RequestPatch(f)

        with open("tests/test_data/getvalidreff.xml", "r") as f:
            self.getValidReff_single = RequestPatch(f)
            self.getValidReff = RequestPatchChained(
                [self.getCapabilities, self.getValidReff_single])

        with open("tests/test_data/getpassage.xml", "r") as f:
            self.getPassage = RequestPatch(f)
            self.getPassage_Capabilities = RequestPatchChained(
                [self.getCapabilities, self.getPassage])

        with open("tests/test_data/getpassageplus.xml", "r") as f:
            self.getPassagePlus = RequestPatch(f)

        with open("tests/test_data/getprevnext.xml", "r") as f:
            self.getPrevNext = RequestPatch(f)
            self.getPassage_Route = RequestPatchChained(
                [self.getCapabilities, self.getPassage, self.getPrevNext])

        self.nemo = Nemo(resolver=NemoResource.endpoint, app=Flask(__name__))
Beispiel #2
0
 def setUp(self):
     a = Citation(name="line")
     b = Citation(name="poem", child=a)
     self.citation = Citation(name="book", child=b)
     self.url = "http://services.perseids.org/api/cts"
     self.endpoint = CTS(self.url)
     self.endpoint.getPassage = mock.MagicMock(return_value=GET_PASSAGE)
     self.endpoint.getPrevNextUrn = mock.MagicMock(return_value=NEXT_PREV)
     self.endpoint.getFirstUrn = mock.MagicMock(return_value=Get_FIRST)
     self.text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2",
                      self.endpoint,
                      citation=self.citation)
Beispiel #3
0
    def test_first_urn_when_empty(self):

        endpoint = CTS(self.url)
        endpoint.getFirstUrn = mock.MagicMock(return_value=Get_FIRST_EMPTY)
        text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2",
                    resource=endpoint)
        passage = Passage(urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1",
                          resource=GET_PASSAGE,
                          parent=text)
        self.assertEqual(
            passage.first, None,
            "Endpoint should be called and none should be returned if there is none"
        )
        endpoint.getFirstUrn.assert_called_with(
            "urn:cts:latinLit:phi1294.phi002.perseus-lat2:1")
Beispiel #4
0
 def setUp(self):
     a = Citation(name="line")
     b = Citation(name="poem", child=a)
     self.citation = Citation(name="book", child=b)
     self.endpoint = CTS("http://services.perseids.org/api/cts")