def test_first_urn(self, requests): text = CtsText("urn:cts:latinLit:phi1294.phi002.perseus-lat2", retriever=self.endpoint) requests.return_value.text = Get_FIRST first = text.getFirstUrn() self.assertEqual(str(first), "1.pr", "Endpoint should be called and URN should be parsed") requests.assert_called_with( "http://services.perseids.org/remote/cts", params={ "request": "GetFirstUrn", "urn": "urn:cts:latinLit:phi1294.phi002.perseus-lat2" })
def test_first_urn_when_empty(self, requests): text = CtsText("urn:cts:latinLit:phi1294.phi002.perseus-lat2", retriever=self.endpoint) requests.return_value.text = Get_FIRST_EMPTY first = text.getFirstUrn() self.assertEqual( first, None, "Endpoint should be called and none should be returned if there is none" ) requests.assert_called_with( "http://services.perseids.org/remote/cts", params={ "request": "GetFirstUrn", "urn": "urn:cts:latinLit:phi1294.phi002.perseus-lat2" })