jenkins-bot has submitted this change and it was merged.
Change subject: Disable a part of testRecentChanges on wikidata
......................................................................
Disable a part of testRecentChanges on wikidata
Split the test method testRecentChanges and testSearch
into separate classes, and disable test_ns_file on
wikidata.
Bug: T101502
Change-Id: I39c5dfb18258a1f98f5d2c93b32a5880975c8fc5
---
M tests/site_tests.py
1 file changed, 57 insertions(+), 5 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 329be12..871ef3e 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -956,22 +956,37 @@
end=pywikibot.Timestamp.fromISOformat('2008-02-03T00:00:01Z'),
reverse=True, total=5)
- def testRecentchanges(self):
- """Test the site.recentchanges() method."""
- mysite = self.get_site()
- mainpage = self.get_mainpage()
+
+class TestRecentChanges(DefaultSiteTestCase):
+
+ """Test recentchanges method."""
+
+ @classmethod
+ def setUpClass(cls):
+ """Test up test class."""
+ super(TestRecentChanges, cls).setUpClass()
+ mysite = cls.get_site()
try:
# 1st image on main page
imagepage = next(iter(mysite.allimages()))
except StopIteration:
print("No images on site {0!r}".format(mysite))
imagepage = None
+ cls.imagepage = imagepage
+
+ def test_basic(self):
+ """Test the site.recentchanges() method."""
+ mysite = self.site
rc = list(mysite.recentchanges(total=10))
self.assertLessEqual(len(rc), 10)
self.assertTrue(all(isinstance(change, dict)
for change in rc))
+
+ def test_time_range(self):
+ """Test the site.recentchanges() method with
start/end."""
+ mysite = self.site
for change in mysite.recentchanges(
- start=pywikibot.Timestamp.fromISOformat('2008-10-01T01:02:03Z'),
+
start=pywikibot.Timestamp.fromISOformat("2008-10-01T01:02:03Z"),
total=5):
self.assertIsInstance(change, dict)
self.assertLessEqual(change['timestamp'],
"2008-10-01T01:02:03Z")
@@ -1013,6 +1028,13 @@
start=pywikibot.Timestamp.fromISOformat("2008-02-03T23:59:59Z"),
end=pywikibot.Timestamp.fromISOformat('2008-02-03T00:00:01Z'),
reverse=True, total=5)
+
+ def test_ns_file(self):
+ """Test the site.recentchanges() method with File: and File
talk:."""
+ if self.site.code == 'wikidata':
+ raise unittest.SkipTest(
+ 'MediaWiki bug frequently occurring on Wikidata. T101502')
+ mysite = self.site
for change in mysite.recentchanges(namespaces=[6, 7], total=5):
self.assertIsInstance(change, dict)
self.assertIn('title', change)
@@ -1022,6 +1044,12 @@
prefix = title[:title.index(":")]
self.assertIn(self.site.namespaces.lookup_name(prefix).id, [6, 7])
self.assertIn(change["ns"], [6, 7])
+
+ def test_pagelist(self):
+ """Test the site.recentchanges() with pagelist deprecated MW
1.14."""
+ mysite = self.site
+ mainpage = self.get_mainpage()
+ imagepage = self.imagepage
if MediaWikiVersion(mysite.version()) <= MediaWikiVersion("1.14"):
pagelist = [mainpage]
if imagepage:
@@ -1032,11 +1060,19 @@
self.assertIsInstance(change, dict)
self.assertIn("title", change)
self.assertIn(change["title"], titlelist)
+
+ def test_changetype(self):
+ """Test the site.recentchanges() with
changetype."""
+ mysite = self.site
for typ in ("edit", "new", "log"):
for change in mysite.recentchanges(changetype=typ, total=5):
self.assertIsInstance(change, dict)
self.assertIn("type", change)
self.assertEqual(change["type"], typ)
+
+ def test_flags(self):
+ """Test the site.recentchanges() with boolean
flags."""
+ mysite = self.site
for change in mysite.recentchanges(showMinor=True, total=5):
self.assertIsInstance(change, dict)
self.assertIn("minor", change)
@@ -1059,6 +1095,17 @@
for change in mysite.recentchanges(showRedirects=False, total=5):
self.assertIsInstance(change, dict)
self.assertNotIn("redirect", change)
+
+
+class TestUserRecentChanges(DefaultSiteTestCase):
+
+ """Test recentchanges method requiring a user."""
+
+ user = True
+
+ def test_patrolled(self):
+ """Test the site.recentchanges() with patrolled boolean
flags."""
+ mysite = self.site
for change in mysite.recentchanges(showPatrolled=True, total=5):
self.assertIsInstance(change, dict)
if mysite.has_right('patrol'):
@@ -1068,6 +1115,11 @@
if mysite.has_right('patrol'):
self.assertNotIn("patrolled", change)
+
+class SearchTestCase(DefaultSiteTestCase):
+
+ """Test search method."""
+
def testSearch(self):
"""Test the site.search() method."""
mysite = self.get_site()
--
To view, visit
https://gerrit.wikimedia.org/r/226057
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I39c5dfb18258a1f98f5d2c93b32a5880975c8fc5
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>