Example #1
0
 def test_get_capabilities_nocites(self):
     """ Check Get Capabilities latinLit data"""
     Repository = XMLFolderResolver(
         ["./tests/test_data/latinLit"]
     )
     self.assertEqual(
         len(Repository.getCapabilities(urn="urn:cts:latinLit:stoa0045.stoa008.perseus-lat2")[0]), 0,
         "Texts without citations were ignored"
     )
Example #2
0
 def test_text_resource(self):
     """ Test to get the text resource to perform other queries """
     Repository = XMLFolderResolver(["./tests/test_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.getPassage(Reference("1.1.1.1")).text(),
         "Ho ! Saki, pass around and offer the bowl (of love for God) : ### ",
         "It should be possible to retrieve text"
     )
Example #3
0
class ResponseTest(TestCase):

    def setUp(self):
        self.inventory = XMLFolderResolver(["./tests/test_data/farsiLit"])

    def test_xml_capabilities(self):
        """ Check consistancy of XML response for Capabilites Response Maker """
        response = getcapabilities([
            self.inventory.inventory["urn:cts:farsiLit:hafez.divan.perseus-eng1"],
            self.inventory.inventory["urn:cts:farsiLit:hafez.divan.perseus-ger1"]
        ])
        ti = TextInventory(resource=response)
        self.assertEqual(
            len(ti["urn:cts:farsiLit:hafez.divan"].texts), 2,
            "Asserts that only two texts has been added to the TI"
        )
        self.assertEqual(
            len(ti["urn:cts:farsiLit:hafez.divan.perseus-eng1"].citation), 4
        )

    def test_with_get_capabilities(self):
        response = getcapabilities(*self.inventory.getCapabilities(category="translation"))
        ti = TextInventory(resource=response)
        self.assertEqual(
            len(ti["urn:cts:farsiLit:hafez.divan"].texts), 2,
            "Asserts that only two texts has been added to the TI"
        )
Example #4
0
 def test_get_shared_textgroup_cross_repo(self):
     """ Check Get Capabilities """
     Repository = XMLFolderResolver(
         [
             "./tests/test_data/farsiLit",
             "./tests/test_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"
     )
Example #5
0
 def setUp(self):
     self.inventory = XMLFolderResolver(["./tests/test_data/farsiLit"])
Example #6
0
 def test_get_capabilities(self):
     """ Check Get Capabilities """
     Repository = XMLFolderResolver(
         ["./tests/test_data/farsiLit"]
     )
     self.assertEqual(
         len(Repository.getCapabilities()[0]), 4,
         "General no filter works"
     )
     self.assertEqual(
         len(Repository.getCapabilities(category="edition")[0]), 2,
         "Type filter works"
     )
     self.assertEqual(
         len(Repository.getCapabilities(lang="ger")[0]), 1,
         "Filtering on language works"
     )
     self.assertEqual(
         len(Repository.getCapabilities(category="edition", lang="ger")[0]), 0,
         "Type filter + lang works"
     )
     self.assertEqual(
         len(Repository.getCapabilities(category="translation", lang="ger")[0]), 1,
         "Type filter + lang works"
     )
     self.assertEqual(
         len(Repository.getCapabilities(page=1, limit=2)[0]), 2,
         "Pagination works without other filters"
     )
     self.assertEqual(
         len(Repository.getCapabilities(page=2, limit=2)[0]), 2,
         "Pagination works without other filters at list end"
     )
     self.assertEqual(
         len(Repository.getCapabilities(urn="urn:cts:farsiLit")[0]), 3,
         "URN Filtering works"
     )
     self.assertEqual(
         len(Repository.getCapabilities(urn="urn:cts:latinLit")[0]), 1,
         "URN Filtering works"
     )
     self.assertEqual(
         len(Repository.getCapabilities(urn="urn:cts:farsiLit:hafez.divan.perseus-eng1")[0]), 1,
         "Complete URN filtering works"
     )