http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11613
Revision: 11613 Author: legoktm Date: 2013-06-02 12:02:35 +0000 (Sun, 02 Jun 2013) Log Message: ----------- Add a unit test that verifies the cached data is read correctly
Modified Paths: -------------- branches/rewrite/tests/api_tests.py
Modified: branches/rewrite/tests/api_tests.py =================================================================== --- branches/rewrite/tests/api_tests.py 2013-06-02 11:40:03 UTC (rev 11612) +++ branches/rewrite/tests/api_tests.py 2013-06-02 12:02:35 UTC (rev 11613) @@ -6,6 +6,7 @@ # __version__ = '$Id$'
+import datetime import unittest import pywikibot import pywikibot.data.api as api @@ -71,6 +72,22 @@ self.assert_(page.title() in titles)
+class TestCachedRequest(unittest.TestCase): + def testResults(self): + # Run the cached query twice to ensure the + # data returned is equal + params = {'action': 'query', + 'prop': 'info', + 'titles': 'Main Page', + } + req = api.CachedRequest(datetime.timedelta(minutes=10), + site=mysite, **params) + data = req.submit() + req2 = api.CachedRequest(datetime.timedelta(minutes=10), + site=mysite, **params) + data2 = req2.submit() + self.assertEqual(data, data2) + if __name__ == '__main__': try: unittest.main()
pywikipedia-svn@lists.wikimedia.org