jenkins-bot has submitted this change and it was merged.
Change subject: Mark site.patrol() as a user write action
......................................................................
Mark site.patrol() as a user write action
Set the patrol test case to be 'write' so that it is
disabled by default, and only run on the 'test:test' site.
Fix SiteWriteMixin so that
- use of 'write' and 'cached' attributes always cause an error
even if write tests are not enabled with PYWIKIBOT2_TEST_WRITE
- an error occurs if write tests are run on sites which haven't
been configured as test sites using Family.test_codes, however
they are skipped on non-test sites when PYWIKIBOT2_TEST_WRITE is
not enabled.
Change-Id: I0ab4dc20f82857505236c0c678a602c02c001e37
---
M pywikibot/families/test_family.py
M pywikibot/site.py
M tests/aspects.py
M tests/site_tests.py
4 files changed, 19 insertions(+), 6 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/families/test_family.py
b/pywikibot/families/test_family.py
index fa26d62..4a80e7d 100644
--- a/pywikibot/families/test_family.py
+++ b/pywikibot/families/test_family.py
@@ -14,3 +14,4 @@
name = 'test'
domain = 'test.wikipedia.org'
+ test_codes = ('test', )
diff --git a/pywikibot/site.py b/pywikibot/site.py
index e9d1100..e88ab36 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4979,6 +4979,7 @@
"notpatrollable": "The revision %(revid)s can't be patrolled as it's
too old."
}
+ @must_be(group='user')
@deprecated_args(token=None)
def patrol(self, rcid=None, revid=None, revision=None):
"""Return a generator of patrolled pages.
diff --git a/tests/aspects.py b/tests/aspects.py
index 0ed694f..1add9e2 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -539,10 +539,15 @@
Otherwise the test class is skipped unless environment variable
PYWIKIBOT2_TEST_WRITE is set to 1.
"""
+ if issubclass(cls, ForceCacheMixin):
+ raise Exception(
+ '%s can not be a subclass of both '
+ 'SiteWriteMixin and ForceCacheMixin'
+ % cls.__name__)
+
super(SiteWriteMixin, cls).setUpClass()
site = cls.get_site()
- assert 'test' in (site.family.name, site.code)
if cls.write == -1:
env_var = 'PYWIKIBOT2_TEST_WRITE_FAIL'
@@ -555,11 +560,13 @@
'Set %s=1 to enable.'
% (cls.__name__, env_var))
- if issubclass(cls, ForceCacheMixin):
+ if (not hasattr(site.family, 'test_codes') or
+ site.code not in site.family.test_codes):
raise Exception(
- '%s can not be a subclass of both '
- 'SiteEditTestCase and ForceCacheMixin'
- % cls.__name__)
+ '%s should only be run on test sites. '
+ 'To run this test, add \'%s\' to the %s family '
+ 'attribute \'test_codes\'.'
+ % (cls.__name__, site.code, site.family.name))
class RequireUserMixin(TestCaseBase):
diff --git a/tests/site_tests.py b/tests/site_tests.py
index b7c7038..a7ef0f1 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1620,12 +1620,16 @@
raise unittest.SkipTest('Test usernames not found')
-class PatrolTestCase(TokenTestBase, DefaultSiteTestCase):
+class PatrolTestCase(TokenTestBase, TestCase):
"""Test patrol method."""
+ family = 'test'
+ code = 'test'
+
user = True
token_type = 'patrol'
+ write = True
def testPatrol(self):
"""Test the site.patrol() method."""
--
To view, visit https://gerrit.wikimedia.org/r/233912
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0ab4dc20f82857505236c0c678a602c02c001e37
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits