jenkins-bot merged this change.
[bugfix] Don't patch the site.unconnected_pages
When returning the site method by the generator, the method couldn't be
patched later because the origin method is already given. Compare the
request parameters instead.
Also fix the iilimit dict entry introduced with T194233
Bug: T195044
Bug: T194233
Change-Id: I614caf7db2264943556649774e92efca8adc9dc6
---
M tests/pagegenerators_tests.py
M tests/site_tests.py
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index b1bf150..db7a33c 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -23,9 +23,9 @@
CategorizedPageGenerator
)
-from pywikibot.tools import has_module
+from pywikibot.tools import has_module, suppress_warnings
-from tests import join_data_path, patch
+from tests import join_data_path
from tests.aspects import (
unittest,
TestCase,
@@ -1484,15 +1484,21 @@
"""Test UnconnectedPageGenerator."""
if not self.site.data_repository():
raise unittest.SkipTest('Site is not using a Wikibase repository')
- upgen = pagegenerators.UnconnectedPageGenerator(self.site, 3)
-
- def unconnected_pages(total=None):
- """Assert unconnected_pages is called correctly."""
- self.assertEqual(total, 3)
- yield
-
- with patch.object(self.site, 'unconnected_pages', unconnected_pages):
- self.assertEqual(tuple(upgen), (None,))
+ with suppress_warnings(
+ 'pywikibot.pagegenerators.UnconnectedPageGenerator is '
+ 'deprecated', DeprecationWarning):
+ upgen = pagegenerators.UnconnectedPageGenerator(self.site, 3)
+ self.assertDictEqual(
+ upgen.request._params, {
+ 'gqppage': ['UnconnectedPages'],
+ 'prop': ['info', 'imageinfo', 'categoryinfo'],
+ 'inprop': ['protection'],
+ 'iilimit': ['max'],
+ 'iiprop': ['timestamp', 'user', 'comment', 'url', 'size',
+ 'sha1', 'metadata'],
+ 'generator': ['querypage'], 'action': ['query'],
+ 'indexpageids': [True], 'continue': [True]})
+ self.assertLessEqual(len(tuple(upgen)), 3)
def test_unconnected_without_repo(self):
"""Test that it raises a ValueError on sites without repository."""
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 3a8be4b..8d78737 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -569,6 +569,7 @@
'titles': [self.mainpage.title()],
'prop': ['info', 'imageinfo', 'categoryinfo'],
'inprop': ['protection'],
+ 'iilimit': ['max'],
'iiprop': ['timestamp', 'user', 'comment', 'url', 'size',
'sha1', 'metadata'],
'generator': ['templates'], 'action': ['query'],
@@ -600,6 +601,7 @@
'redirects': [False],
'prop': ['info', 'imageinfo', 'categoryinfo'],
'inprop': ['protection'],
+ 'iilimit': ['max'],
'iiprop': ['timestamp', 'user', 'comment', 'url', 'size',
'sha1', 'metadata'], 'generator': ['links'],
'action': ['query'], 'indexpageids': [True], 'continue': [True]}
@@ -1094,6 +1096,7 @@
'gqppage': ['UnconnectedPages'],
'prop': ['info', 'imageinfo', 'categoryinfo'],
'inprop': ['protection'],
+ 'iilimit': ['max'],
'iiprop': ['timestamp', 'user', 'comment', 'url', 'size',
'sha1', 'metadata'],
'generator': ['querypage'], 'action': ['query'],
To view, visit change 433962. To unsubscribe, visit settings.