def test_get_shared_textgroup_cross_repo(self): """ Check Get Capabilities """ Repository = CtsCapitainsLocalResolver([ "./tests/testing_data/farsiLit", "./tests/testing_data/latinLit2" ]) self.assertIsNotNone( Repository.__getText__( "urn:cts:latinLit:phi1294.phi002.perseus-lat2"), "We should find perseus-lat2") self.assertIsNotNone( Repository.__getText__("urn:cts:latinLit:phi1294.phi002.opp-lat2"), "We should find perseus-lat2")
def test_missing_text_resource(self): """ Test to make sure the correct warning is raised if a text is missing """ with self.assertLogs(CtsCapitainsLocalResolver(["./tests/testing_data/missing_text"]).logger) as cm: Repository = CtsCapitainsLocalResolver(["./tests/testing_data/missing_text"]) text, metadata = Repository.__getText__("urn:cts:farsiLit:hafez.divan.missing_text") self.assertIsNone(text) self.assertIn('WARNING:root:The file ' './tests/testing_data/missing_text/data/hafez/divan/hafez.divan.missing_text.xml ' 'is mentioned in the metadata but does not exist', cm.output) self.assertIn( 'ERROR:root:./tests/testing_data/missing_text/data/hafez/divan/hafez.divan.missing_text.xml is not present', cm.output )
def test_text_resource(self): """ Test to get the text resource to perform other queries """ Repository = CtsCapitainsLocalResolver(["./tests/testing_data/farsiLit"]) text, metadata = Repository.__getText__("urn:cts:farsiLit:hafez.divan.perseus-eng1") self.assertEqual( len(text.citation), 4, "Object has a citation property of length 4" ) self.assertEqual( text.getTextualNode(CtsReference("1.1.1.1")).export(output=Mimetypes.PLAINTEXT), "Ho ! Saki, pass around and offer the bowl (of love for God) : ### ", "It should be possible to retrieve text" )