jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/333328 )
Change subject: Make ItemClaimFilter.__filter_match always return bool
......................................................................
Make ItemClaimFilter.__filter_match always return bool
And also improve ItemClaimFilter.filter's documentation.
Change-Id: Ifecbc61809a4cf1a6c736deb8b70601f19f8d404
---
M pywikibot/pagegenerators.py
1 file changed, 4 insertions(+), 3 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index afb752c..fc5060c 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -1518,20 +1518,21 @@
if not page_claim.has_qualifier(prop, val):
return False
return True
+ return False
@classmethod
def filter(cls, generator, prop, claim, qualifiers=None, negate=False):
"""
- Yield all ItemPages which does contain certain claim in a property.
+ Yield all ItemPages which contain certain claim in a property.
@param prop: property id to check
@type prop: str
@param claim: value of the property to check. Can be exact value (for
- instance, ItemPage instance) or ItemPage ID string (e.g. 'Q37470').
+ instance, ItemPage instance) or a string (e.g. 'Q37470').
@param qualifiers: dict of qualifiers that must be present, or None if
qualifiers are irrelevant
@type qualifiers: dict or None
- @param negate: true if pages that does *not* contain specified claim
+ @param negate: true if pages that do *not* contain specified claim
should be yielded, false otherwise
@type negate: bool
"""
--
To view, visit https://gerrit.wikimedia.org/r/333328
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifecbc61809a4cf1a6c736deb8b70601f19f8d404
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/333291 )
Change subject: page_tests.py: Add a dry test for FilePage.get_file_history
......................................................................
page_tests.py: Add a dry test for FilePage.get_file_history
12987c8085dbfd4e63ee3346d55e97795e734f8a fixed a bug in get_file_history
that was preventing the file history from being loaded. This patch adds
a test for that method which previously was not covered in any test.
Bug: T155740
Change-Id: I9b6b333eb562227a272a862f1edf5c25544a319b
---
M tests/page_tests.py
1 file changed, 26 insertions(+), 3 deletions(-)
Approvals:
jenkins-bot: Verified
Sn1per: Looks good to me, approved
diff --git a/tests/page_tests.py b/tests/page_tests.py
index ebb9a38..1af59a2 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -1,15 +1,17 @@
# -*- coding: utf-8 -*-
"""Tests for the page module."""
#
-# (C) Pywikibot team, 2008-2016
+# (C) Pywikibot team, 2008-2017
#
# Distributed under the terms of the MIT license.
#
from __future__ import absolute_import, unicode_literals
-__version__ = '$Id$'
-
import pickle
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pywikibot
import pywikibot.page
@@ -28,6 +30,9 @@
unittest, TestCase, DefaultSiteTestCase, SiteAttributeTestCase,
DefaultDrySiteTestCase, DeprecationTestCase,
)
+
+
+__version__ = '$Id$'
class TestLinkObject(SiteAttributeTestCase):
@@ -566,6 +571,24 @@
cls.page = pywikibot.Page(cls.site, 'Ō')
+class TestPageGetFileHistory(DefaultDrySiteTestCase):
+
+ """Test the get_file_history method of the FilePage class."""
+
+ def test_get_file_history_cache(self):
+ """Test the cache mechanism of get_file_history."""
+ with mock.patch.object(self.site, 'loadimageinfo', autospec=True):
+ page = pywikibot.FilePage(self.site, 'File:Foo.jpg')
+ _file_revisions = page.get_file_history()
+ # On the first call the history is loaded via API
+ self.assertEqual(_file_revisions, {})
+ # Fill the cache
+ _file_revisions['foo'] = 'bar'
+ # On the second call page._file_revisions is returned
+ self.assertEqual(page.get_file_history(), {'foo': 'bar'})
+ self.site.loadimageinfo.assert_called_once_with(page, history=True)
+
+
class TestPageRepr(TestPageBaseUnicode):
"""Test for Page's repr implementation."""
--
To view, visit https://gerrit.wikimedia.org/r/333291
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9b6b333eb562227a272a862f1edf5c25544a319b
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Sn1per <geofbot(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/333215 )
Change subject: FilePage.get_file_history(): Check for len(self._file_revisions)
......................................................................
FilePage.get_file_history(): Check for len(self._file_revisions)
Previously it was hasattr(self, '_file_revisions'), which will always
return True due to attribute being set on instance initialization.
Unlike other cacheing logic such as templates or categories that use
hasattr check, we keep this logic of len check due to the fact that
a file page must have a file revision, and many methods expects the
self._file_revisions dict to be non-empty.
Bug: T155740
Change-Id: I4f35971a3f45f6ffed20135f45c5050f862a0d92
---
M pywikibot/page.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index e7aa8e3..f015e45 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2346,7 +2346,7 @@
value: instance of FileInfo()
@rtype: dict
"""
- if not hasattr(self, '_file_revisions'):
+ if not len(self._file_revisions):
self.site.loadimageinfo(self, history=True)
return self._file_revisions
--
To view, visit https://gerrit.wikimedia.org/r/333215
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4f35971a3f45f6ffed20135f45c5050f862a0d92
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #3804
Status: Errored
Duration: 45 minutes and 30 seconds
Commit: 0c33e28 (master)
Author: zhuyifei1999
Message: GeneratorFactory: make getCategory respect self.site
Previous behavior is to generate the pages with the site in
user-config, regardless of the value in self.site.
Bug: T155687
Change-Id: Ic0400fd45b0f44dda65a6b69d6a9c4a7ed5d35ef
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/ef42bb198ba5...0c33e289…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/193678593
--
You can configure recipients for build notifications in your .travis.yml file. See https://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/332939 )
Change subject: GeneratorFactory: make getCategory respect self.site
......................................................................
GeneratorFactory: make getCategory respect self.site
Previous behavior is to generate the pages with the site in
user-config, regardless of the value in self.site.
Bug: T155687
Change-Id: Ic0400fd45b0f44dda65a6b69d6a9c4a7ed5d35ef
---
M pywikibot/pagegenerators.py
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
Mpaa: Looks good to me, but someone else must approve
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index c290fd6..afb752c 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -544,6 +544,7 @@
categoryname = u'{0}:{1}'.format(self.site.namespace(14),
categoryname)
cat = pywikibot.Category(pywikibot.Link(categoryname,
+ source=self.site,
defaultNamespace=14))
return cat, startfrom
--
To view, visit https://gerrit.wikimedia.org/r/332939
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic0400fd45b0f44dda65a6b69d6a9c4a7ed5d35ef
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>