def test_thank_revision(self): """Test thanks for normal revisions. NOTE: This test relies on activity in recentchanges, and there must make edits made before reruns of this test. Please see https://phabricator.wikimedia.org/T137836. """ found_log = False site = self.get_site() data = site.recentchanges(total=20) for rev in data: revid = rev['revid'] username = rev['user'] user = User(site, username) if user.is_thankable: break else: self.skipTest(NO_THANKABLE_REVS) before_time = site.getcurrenttimestamp() Revision._thank(revid, site, source='pywikibot test') log_entries = site.logevents(logtype='thanks', total=5, page=user, start=before_time, reverse=True) for __ in log_entries: found_log = True break self.assertTrue(found_log)
def creator(self): """The creator of this post.""" if not hasattr(self, '_current_revision'): self._load() if not hasattr(self, '_creator'): self._creator = User(self.site, self._current_revision['creator']['name']) return self._creator
def test_bad_recipient(self): """Test that thanking a bad recipient causes an error.""" site = self.get_site() data = site.recentchanges(total=20) for rev in data: revid = rev['revid'] username = rev['user'] user = User(site, username) if not user.is_thankable: break else: self.skipTest(NO_THANKABLE_REVS) self.assertAPIError('invalidrecipient', None, site.thank_revision, revid, source='pywikibot test')