55'''
66import unittest
77from unittest .mock import patch
8- from wikibot .smw import SMW , SMWBot , SMWClient , QueryResultSizeExceedException , SplitClause
9- from wikibot .wikibot import WikiBot
10- from wikibot .wikiclient import WikiClient
8+ from wikibot3rd .smw import SMW , SMWBot , SMWClient , QueryResultSizeExceedException , SplitClause
9+ from wikibot3rd .wikibot import WikiBot
10+ from wikibot3rd .wikiclient import WikiClient
1111from tests .test_wikibot import TestWikiBot
1212from tests .test_WikiUser import TestWikiUser
1313from datetime import datetime
@@ -329,8 +329,8 @@ def _askForAllResults_mock_sideEffect(query,limit):
329329 if query == expectedQuery :
330330 return [RESULT_N (i )]
331331
332- with patch ("wikibot .smw.SMWClient.askForAllResults" ) as askForAllResults_mock , \
333- patch ("wikibot .smw.SMWClient.getBoundariesOfQuery" ) as getBoundariesOfQuery :
332+ with patch ("wikibot3rd .smw.SMWClient.askForAllResults" ) as askForAllResults_mock , \
333+ patch ("wikibot3rd .smw.SMWClient.getBoundariesOfQuery" ) as getBoundariesOfQuery :
334334 getBoundariesOfQuery .return_value = (datetime .strptime ("01/01/2020 00:00:00" , '%d/%m/%Y %H:%M:%S' ),
335335 datetime .strptime ("11/01/2020 00:00:00" , '%d/%m/%Y %H:%M:%S' ))
336336 askForAllResults_mock .side_effect = _askForAllResults_mock_sideEffect
@@ -408,8 +408,8 @@ def askForAllResults_mock_side_effect(query, limit=None, kwargs={}):
408408 for smw in self .getSMWs ():
409409 if isinstance (smw , SMWClient ):
410410 # Test default case
411- with patch ("wikibot .smw.SMWClient.askForAllResults" ) as askForAllResults_mock , \
412- patch ("wikibot .smw.SMWClient.askPartitionQuery" ) as askPartitionQuery_mock :
411+ with patch ("wikibot3rd .smw.SMWClient.askForAllResults" ) as askForAllResults_mock , \
412+ patch ("wikibot3rd .smw.SMWClient.askPartitionQuery" ) as askPartitionQuery_mock :
413413 askForAllResults_mock .return_value = [RESULT ]
414414 askPartitionQuery_mock .return_value = None
415415 result = smw .ask (QUERY )
@@ -418,8 +418,8 @@ def askForAllResults_mock_side_effect(query, limit=None, kwargs={}):
418418 self .assertEqual (askPartitionQuery_mock .call_count , 0 )
419419 # Test if query division is used if 'queryDivision' attribute is set above 1
420420 smw .queryDivision = 10
421- with patch ("wikibot .smw.SMWClient.askForAllResults" ) as askForAllResults_mock , \
422- patch ("wikibot .smw.SMWClient.askPartitionQuery" ) as askPartitionQuery_mock :
421+ with patch ("wikibot3rd .smw.SMWClient.askForAllResults" ) as askForAllResults_mock , \
422+ patch ("wikibot3rd .smw.SMWClient.askPartitionQuery" ) as askPartitionQuery_mock :
423423 askForAllResults_mock .return_value = None
424424 askPartitionQuery_mock .return_value = [RESULT ]
425425 result = smw .ask (QUERY )
@@ -535,6 +535,20 @@ def testIssue82(self):
535535 result = self .getAskResult (smw , ask , limit = 5 )
536536 self .assertTrue (len (result ) == 5 , name + smw .site .host + smw .site .path )
537537
538+ def testIssue86 (self ):
539+ """
540+ test allowing count queries
541+ """
542+ smw = self .getSMWs ("smwcopy" )[1 ]
543+ askQuery = """{{#ask: [[Modification date::+]]
544+ |format=count
545+ }}"""
546+ result = smw .query (askQuery )
547+ debug = self .debug
548+ debug = True
549+ if debug :
550+ print (result )
551+ # @FIXME - fix when https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/4857 is fixed
538552
539553if __name__ == "__main__" :
540554 #import sys;sys.argv = ['', 'Test.testSMWApi']
0 commit comments