# -*- coding: utf-8 -*- """Test suite for the thanks script""" # # (C) Pywikibot team, 2016 # # Distributed under the terms of the MIT license. # from __future__ import absolute_import, unicode_literals import pywikibot from scripts.thanks import thank_rev from tests.aspects import unittest, TestCase class TestRevThank(TestCase): """Test thanks for revisions.""" family = 'test' code = 'test' 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. """ site = pywikibot.Site() data = site.recentchanges(total=1) for i in data: rev_id = i['revid'] log_initial = site.logevents(logtype='thanks', total=1) for x in log_initial: initial_id = x.logid() thank_rev(rev_id) log_final = site.logevents(logtype='thanks', total=1) for x in log_final: final_id = x.logid() self.assertNotEqual(initial_id,final_id) if __name__ == "__main__": unittest.main()