Example #1
0
    def testWikiQuery(self):
        '''
        https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/56
        '''
        # make sure the CI wikiUser is prepared
        if self.inPublicCI(): return
        wikiId = 'or'
        wikiClient = self.getWikiClient(wikiId)
        wikiPush = WikiPush(fromWikiId=wikiId)
        askQuery = """{{#ask: [[IsA::Event]][[Ordinal::>2]][[start date::>2018]][[start date::<2019]]
| mainlabel = Event
| ?Title = title
| ?Event in series = series
| ?_CDAT=creation date
| ?_MDAT=modification date
| ?ordinal=ordinal
| ?Homepage = homepage
|format=table
}}"""
        for outputFormat in ["csv", "json", "xml", "ttl", "wikidata", "lod"]:
            formatedQueryResults = wikiPush.formatQueryResult(
                askQuery,
                wikiClient,
                outputFormat=outputFormat,
                entityName="Event")
            if formatedQueryResults:
                if self.debug:
                    print(formatedQueryResults)
            else:
                if self.debug:
                    print(f"Format {outputFormat} is not supported.")
        pass
Example #2
0
 def testLOD(self):
     """Test if LOD is returned correctly if called form api"""
     wikiId = 'or'
     wikiClient = self.getWikiClient(wikiId)
     wikiPush = WikiPush(fromWikiId=wikiId)
     askQuery = "{{#ask:" + self.eventQuery + "}}"
     lod_res = wikiPush.formatQueryResult(askQuery,
                                          wikiClient,
                                          entityName="Event")
     if self.debug:
         print(lod_res)
     self.assertTrue(isinstance(lod_res, list))
     self.assertTrue(isinstance(lod_res[0], dict))
 def testIssue66(self):
     '''
     test TypeError("'dict_values' object is not subscriptable")
     '''
     if self.inPublicCI(): return
     wikiId = 'wgt'
     wikiClient = self.getWikiClient(wikiId)
     wikiClient.login()
     wikiPush = WikiPush(fromWikiId=wikiId)
     askQuery = "{{#ask:[[Modification date::+]]}}"
     lod_res = wikiPush.formatQueryResult(askQuery,
                                          wikiClient,
                                          queryDivision=10)
     if self.debug:
         print(lod_res)