def test_first_urn_whenreference(self): endpoint = HttpCtsRetriever(self.url) endpoint.getFirstUrn = mock.MagicMock(return_value=Get_FIRST) text = CtsText("urn:cts:latinLit:phi1294.phi002.perseus-lat2", retriever=endpoint) passage = CtsPassage( urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1", resource=GET_PASSAGE, retriever=endpoint) first = passage.getFirstUrn("1.1") endpoint.getFirstUrn.assert_called_with( "urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1") self.assertEqual( first, "1.pr", "Parsing should be done and getFirstUrn should treat correctly full urn" )
def test_first_urn_when_empty(self): endpoint = HttpCtsRetriever(self.url) endpoint.getFirstUrn = mock.MagicMock(return_value=Get_FIRST_EMPTY) text = CtsText("urn:cts:latinLit:phi1294.phi002.perseus-lat2", retriever=endpoint) passage = CtsPassage( urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1", resource=GET_PASSAGE, retriever=endpoint) first = passage.firstId endpoint.getFirstUrn.assert_called_with( "urn:cts:latinLit:phi1294.phi002.perseus-lat2:1") self.assertEqual( first, None, "Endpoint should be called and none should be returned if there is none" )