jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/359366 )
Change subject: Add log entry code for thanks log ......................................................................
Add log entry code for thanks log
There is a server-side parameter, thankid, which stores the object (revision or Flow post) being thanked. It is not exposed by the API and is therefore omitted.
ThanksEntry.page() returns a User instead of a Page.
Bug: T135413 Change-Id: Idb656b3920338d21e9a0d269c59d30597740a058 --- M pywikibot/logentries.py M tests/logentry_tests.py 2 files changed, 28 insertions(+), 1 deletion(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py index 310d826..22cc434 100644 --- a/pywikibot/logentries.py +++ b/pywikibot/logentries.py @@ -360,6 +360,23 @@
_expectedType = 'newusers'
+ +class ThanksEntry(LogEntry): + + """Thanks log entry.""" + + _expectedType = 'thanks' + + def page(self): + """Return the target user. + + This returns a User object instead of the Page object returned by the + superclass method. + """ + if not hasattr(self, '_page'): + self._page = pywikibot.User(super(ThanksEntry, self).page()) + return self._page + # TODO entries for merge,suppress,makebot,gblblock,renameuser,globalauth,gblrights ?
@@ -380,7 +397,8 @@ 'move': MoveEntry, 'import': ImportEntry, 'patrol': PatrolEntry, - 'newusers': NewUsersEntry + 'newusers': NewUsersEntry, + 'thanks': ThanksEntry, }
def __init__(self, site, logtype=None): diff --git a/tests/logentry_tests.py b/tests/logentry_tests.py index 27bf718..8f9128d 100644 --- a/tests/logentry_tests.py +++ b/tests/logentry_tests.py @@ -103,6 +103,8 @@ def test_method(logtype): def test_logevent(self, key): """Test a single logtype entry.""" + if key == 'old' and logtype == 'thanks': + self.skipTest('Thanks extension not on old.') self._test_logevent(logtype)
return test_logevent @@ -215,6 +217,13 @@ with self.assertRaises(pywikibot.NoMoveTarget): page.moved_target()
+ def test_thanks_page(self, key): + """Test Thanks page method return type.""" + if not self.site.has_extension('Thanks'): + self.skipTest('Thanks extension not available.') + logentry = self._get_logentry('thanks') + self.assertIsInstance(logentry.page(), pywikibot.User) +
class TestDeprecatedMethods(TestLogentriesBase, DeprecationTestCase):
pywikibot-commits@lists.wikimedia.org