jenkins-bot has submitted this change and it was merged.
Change subject: proofreadpage.py: workaround to allow purging without write rights
......................................................................
proofreadpage.py: workaround to allow purging without write rights
Implement workaround to mitigate test failures due to Bug T128994.
Purge pages with a Request that does not check write wrights for the
specific purge action needed by IndexPage.
Bug: T128994
Change-Id: Ide2fa5128e17b79d40f0f464fa5221d471218cbe
---
M pywikibot/proofreadpage.py
1 file changed, 36 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index 5996ee7..6b6e684 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -30,6 +30,8 @@
import pywikibot
+from pywikibot.data.api import Request
+
class FullHeader(object):
@@ -420,6 +422,23 @@
return '/* {0.status} */ '.format(self)
+class PurgeRequest(Request):
+
+ """Subclass of Request which skips the check on write rights.
+
+ Workaround for T128994.
+ # TODO: remove once bug is fixed.
+ """
+
+ def __init__(self, **kwargs):
+ """Monkeypatch action in Request constructor."""
+ action = kwargs['parameters']['action']
+ kwargs['parameters']['action'] = 'dummy'
+ super(PurgeRequest, self).__init__(**kwargs)
+ self.action = action
+ self.update({'action': action})
+
+
class IndexPage(pywikibot.Page):
"""Index Page page used in Mediawiki ProofreadPage
extension."""
@@ -481,6 +500,22 @@
else:
return None
+ def purge(self):
+ """Overwrite purge method.
+
+ Workaround for T128994.
+ # TODO: remove once bug is fixed.
+
+ Instead of a proper purge action, use PurgeRequest, which
+ skips the check on write rights.
+ """
+ params = {'action': 'purge', 'titles':
[self.title()]}
+ request = PurgeRequest(site=self.site, parameters=params)
+ rawdata = request.submit()
+ error_message = 'Purge action failed for %s' % self
+ assert 'purge' in rawdata, error_message
+ assert 'purged' in rawdata['purge'][0], error_message
+
def _get_page_mappings(self):
"""Associate label and number for each page linked to the
index."""
# Clean cache, if any.
@@ -517,7 +552,7 @@
self._soup = BeautifulSoup(self._parsed_text, 'html.parser')
if not self._soup.find_all('a', attrs=attrs):
raise ValueError(
- 'Missing class="qualityN prp-pagequality-N" or'
+ 'Missing class="qualityN prp-pagequality-N" or '
'class="new" in: %s.'
% self)
--
To view, visit
https://gerrit.wikimedia.org/r/284754
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ide2fa5128e17b79d40f0f464fa5221d471218cbe
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>