jenkins-bot has submitted this change and it was merged.

Change subject: Split testUsercontribs
......................................................................


Split testUsercontribs

Bug: T78668
Change-Id: I0794ee6db03993d582e91be872856690e708a8e6
---
M tests/site_tests.py
1 file changed, 43 insertions(+), 1 deletion(-)

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 b022919..9c62d93 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1064,7 +1064,14 @@
                 raise unittest.SkipTest("gsrsearch returned timeout on site: 
%r" % e)
             raise
 
-    def testUsercontribs(self):
+
+class TestUserContribs(DefaultSiteTestCase):
+
+    """Test site method site.usercontribs()."""
+
+    user = True
+
+    def test_basic(self):
         """Test the site.usercontribs() method."""
         mysite = self.get_site()
         uc = list(mysite.usercontribs(user=mysite.user(), total=10))
@@ -1073,33 +1080,52 @@
                             for contrib in uc))
         self.assertTrue(all('user' in contrib and contrib['user'] == 
mysite.user()
                             for contrib in uc))
+
+    def test_user_prefix(self):
+        """Test the site.usercontribs() method with userprefix."""
+        mysite = self.get_site()
         for contrib in mysite.usercontribs(userprefix="John", total=5):
             self.assertIsInstance(contrib, dict)
             for key in ("user", "title", "ns", "pageid", "revid"):
                 self.assertIn(key, contrib)
             self.assertTrue(contrib["user"].startswith("John"))
+
+    def test_user_prefix_range(self):
+        """Test the site.usercontribs() method."""
+        mysite = self.get_site()
         for contrib in mysite.usercontribs(userprefix="Jane",
                                            
start=pywikibot.Timestamp.fromISOformat("2008-10-06T01:02:03Z"),
                                            total=5):
             self.assertLessEqual(contrib['timestamp'], "2008-10-06T01:02:03Z")
+
         for contrib in mysite.usercontribs(userprefix="Jane",
                                            
end=pywikibot.Timestamp.fromISOformat("2008-10-07T02:03:04Z"),
                                            total=5):
             self.assertGreaterEqual(contrib['timestamp'], 
"2008-10-07T02:03:04Z")
+
+    def test_user_prefix_reverse(self):
+        """Test the site.usercontribs() method with range reversed."""
+        mysite = self.get_site()
         for contrib in mysite.usercontribs(userprefix="Brion",
                                            
start=pywikibot.Timestamp.fromISOformat("2008-10-08T03:05:07Z"),
                                            total=5, reverse=True):
             self.assertGreaterEqual(contrib['timestamp'], 
"2008-10-08T03:05:07Z")
+
         for contrib in mysite.usercontribs(userprefix="Brion",
                                            
end=pywikibot.Timestamp.fromISOformat("2008-10-09T04:06:08Z"),
                                            total=5, reverse=True):
             self.assertLessEqual(contrib['timestamp'], "2008-10-09T04:06:08Z")
+
         for contrib in mysite.usercontribs(userprefix="Tim",
                                            
start=pywikibot.Timestamp.fromISOformat("2008-10-10T11:59:59Z"),
                                            
end=pywikibot.Timestamp.fromISOformat("2008-10-10T00:00:01Z"),
                                            total=5):
             self.assertTrue(
                 "2008-10-10T00:00:01Z" <= contrib['timestamp'] <= 
"2008-10-10T11:59:59Z")
+
+    def test_invalid_range(self):
+        """Test the site.usercontribs() method with invalid parameters."""
+        mysite = self.get_site()
         for contrib in mysite.usercontribs(userprefix="Tim",
                                            
start=pywikibot.Timestamp.fromISOformat("2008-10-11T06:00:01Z"),
                                            
end=pywikibot.Timestamp.fromISOformat("2008-10-11T23:59:59Z"),
@@ -1117,25 +1143,41 @@
                           start="2008-10-03T23:59:59Z",
                           end="2008-10-03T00:00:01Z", reverse=True, total=5)
 
+    def test_namespaces(self):
+        """Test the site.usercontribs() method using namespaces."""
+        mysite = self.get_site()
         for contrib in mysite.usercontribs(user=mysite.user(),
                                            namespaces=14, total=5):
             self.assertIsInstance(contrib, dict)
             self.assertIn("title", contrib)
             self.assertTrue(contrib["title"].startswith(mysite.namespace(14)))
+
         for contrib in mysite.usercontribs(user=mysite.user(),
                                            namespaces=[10, 11], total=5):
             self.assertIsInstance(contrib, dict)
             self.assertIn("title", contrib)
             self.assertIn(contrib["ns"], (10, 11))
+
+    def test_show_minor(self):
+        """Test the site.usercontribs() method using showMinor."""
+        mysite = self.get_site()
         for contrib in mysite.usercontribs(user=mysite.user(),
                                            showMinor=True, total=5):
             self.assertIsInstance(contrib, dict)
             self.assertIn("minor", contrib)
+
         for contrib in mysite.usercontribs(user=mysite.user(),
                                            showMinor=False, total=5):
             self.assertIsInstance(contrib, dict)
             self.assertNotIn("minor", contrib)
 
+
+class SiteWatchlistRevsTestCase(DefaultSiteTestCase):
+
+    """Test site method watchlist_revs()."""
+
+    user = True
+
     def testWatchlistrevs(self):
         """Test the site.watchlist_revs() method."""
         mysite = self.get_site()

-- 
To view, visit https://gerrit.wikimedia.org/r/219614
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0794ee6db03993d582e91be872856690e708a8e6
Gerrit-PatchSet: 2
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: Merlijn van Deen <[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

Reply via email to