[MediaWiki-commits] [Gerrit] pywikibot/core[master]: [bugfix] Fix purgepages() result

2016-11-27 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: [bugfix] Fix purgepages() result
..


[bugfix] Fix purgepages() result

linkupdates are only done if the value of the key argument is True or None.
Check for the value first.

Test added.

Bug: T151712
Change-Id: I9367ddf02c782694947c1f452a515cea8971819f
---
M pywikibot/site.py
M tests/page_tests.py
2 files changed, 2 insertions(+), 4 deletions(-)

Approvals:
  Magul: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/site.py b/pywikibot/site.py
index 4e8b6e1..cd6b1d4 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -5754,20 +5754,17 @@
 """
 req = self._simple_request(action='purge',
titles=[page for page in set(pages)])
-linkupdate = False
 linkupdate_args = ['forcelinkupdate', 'forcerecursivelinkupdate']
 for arg in kwargs:
 if arg in linkupdate_args + ['redirects', 'converttitles']:
 req[arg] = kwargs[arg]
-if arg in linkupdate_args:
-linkupdate = True
 result = req.submit()
 if 'purge' not in result:
 pywikibot.error(u'purgepages: Unexpected API response:\n%s' % 
result)
 return False
 result = result['purge']
 purged = ['purged' in page for page in result]
-if linkupdate:
+if any(kwargs.get(arg) for arg in linkupdate_args):
 purged += ['linkupdate' in page for page in result]
 return all(purged)
 
diff --git a/tests/page_tests.py b/tests/page_tests.py
index ea2d7da..ebb9a38 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -844,6 +844,7 @@
 """Test purging the mainpage."""
 mainpage = self.get_mainpage()
 self.assertIsInstance(mainpage.purge(), bool)
+self.assertEqual(mainpage.purge(), 
mainpage.purge(forcelinkupdate=None))
 
 def test_watch(self):
 """Test Page.watch, with and without unwatch enabled."""

-- 
To view, visit https://gerrit.wikimedia.org/r/323686
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9367ddf02c782694947c1f452a515cea8971819f
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt 
Gerrit-Reviewer: Dalba 
Gerrit-Reviewer: John Vandenberg 
Gerrit-Reviewer: Magul 
Gerrit-Reviewer: Ricordisamoa 
Gerrit-Reviewer: Xqt 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] pywikibot/core[master]: [bugfix] Fix purgepages() result

2016-11-27 Thread Xqt (Code Review)
Xqt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/323686

Change subject: [bugfix] Fix purgepages() result
..

[bugfix] Fix purgepages() result

linkupdates are only done if the value of the key argument is True or None.
Check for the value first.

Test added.

Bug: T151712
Change-Id: I9367ddf02c782694947c1f452a515cea8971819f
---
M pywikibot/site.py
M tests/page_tests.py
2 files changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/86/323686/1

diff --git a/pywikibot/site.py b/pywikibot/site.py
index 4e8b6e1..413ac87 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -5759,7 +5759,7 @@
 for arg in kwargs:
 if arg in linkupdate_args + ['redirects', 'converttitles']:
 req[arg] = kwargs[arg]
-if arg in linkupdate_args:
+if arg in linkupdate_args and kwargs[arg]:
 linkupdate = True
 result = req.submit()
 if 'purge' not in result:
diff --git a/tests/page_tests.py b/tests/page_tests.py
index ea2d7da..ebb9a38 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -844,6 +844,7 @@
 """Test purging the mainpage."""
 mainpage = self.get_mainpage()
 self.assertIsInstance(mainpage.purge(), bool)
+self.assertEqual(mainpage.purge(), 
mainpage.purge(forcelinkupdate=None))
 
 def test_watch(self):
 """Test Page.watch, with and without unwatch enabled."""

-- 
To view, visit https://gerrit.wikimedia.org/r/323686
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9367ddf02c782694947c1f452a515cea8971819f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits