Dalba has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/335403 )

Change subject: TestUserContribsWithoutUser: Avoid too short prefixes
......................................................................

TestUserContribsWithoutUser: Avoid too short prefixes

Mediawiki has hard time handling short prefixes and failes on these tests
from time to time with causing a timeout or returning 503 response.

To fix the issue, replace the 'Tim' prefix with 'Tim symond' and 'Timshiel'
inside test_user_prefix_range and test_user_prefix_reverse, these values
still return some contributions on enwiki. But they only makes sense on
English Wikipedia. This should not be much of an issue, because even before
this change, very few wikis had contributions with usernames starting with
`Tim` between those specific timespans in 2008.

Also keep lines under 80 characters.

Bug: T134640
Change-Id: I9d47a1884c7bd154b4d5b3b7666ce1345879efb8
---
M tests/site_tests.py
1 file changed, 21 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/03/335403/1

diff --git a/tests/site_tests.py b/tests/site_tests.py
index 2c8744e..5b43ccf 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1489,34 +1489,38 @@
     def test_user_prefix_range(self):
         """Test the site.usercontribs() method."""
         mysite = self.get_site()
+        start = '2008-10-06T01:02:03Z'
         for contrib in mysite.usercontribs(
                 userprefix='Jane',
-                
start=pywikibot.Timestamp.fromISOformat("2008-10-06T01:02:03Z"),
+                start=pywikibot.Timestamp.fromISOformat(start),
                 total=5):
-            self.assertLessEqual(contrib['timestamp'], "2008-10-06T01:02:03Z")
+            self.assertLessEqual(contrib['timestamp'], start)
 
+        end = '2008-10-07T02:03:04Z'
         for contrib in mysite.usercontribs(
                 userprefix='Jane',
-                end=pywikibot.Timestamp.fromISOformat("2008-10-07T02:03:04Z"),
+                end=pywikibot.Timestamp.fromISOformat(end),
                 total=5):
-            self.assertGreaterEqual(contrib['timestamp'], 
"2008-10-07T02:03:04Z")
+            self.assertGreaterEqual(contrib['timestamp'], end)
 
+        start = '2008-10-10T11:59:59Z'
+        end = '2008-10-10T00:00:01Z'
         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"),
+                userprefix='Timshiel',
+                start=pywikibot.Timestamp.fromISOformat(start),
+                end=pywikibot.Timestamp.fromISOformat(end),
                 total=5):
-            self.assertTrue(
-                "2008-10-10T00:00:01Z" <= contrib['timestamp'] <= 
"2008-10-10T11:59:59Z")
+            self.assertTrue(end <= contrib['timestamp'] <= start)
 
     def test_user_prefix_reverse(self):
         """Test the site.usercontribs() method with range reversed."""
         mysite = self.get_site()
+        start = '2008-10-08T03:05:07Z'
         for contrib in mysite.usercontribs(
                 userprefix='Brion',
-                
start=pywikibot.Timestamp.fromISOformat("2008-10-08T03:05:07Z"),
+                start=pywikibot.Timestamp.fromISOformat(start),
                 total=5, reverse=True):
-            self.assertGreaterEqual(contrib['timestamp'], 
"2008-10-08T03:05:07Z")
+            self.assertGreaterEqual(contrib['timestamp'], start)
 
         for contrib in mysite.usercontribs(
                 userprefix='Brion',
@@ -1524,13 +1528,14 @@
                 total=5, reverse=True):
             self.assertLessEqual(contrib['timestamp'], "2008-10-09T04:06:08Z")
 
+        start = '2008-10-11T06:00:01Z'
+        end = '2008-10-11T23:59:59Z'
         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"),
+                userprefix='Tim symond',
+                start=pywikibot.Timestamp.fromISOformat(start),
+                end=pywikibot.Timestamp.fromISOformat(end),
                 reverse=True, total=5):
-            self.assertTrue(
-                "2008-10-11T06:00:01Z" <= contrib['timestamp'] <= 
"2008-10-11T23:59:59Z")
+            self.assertTrue(start <= contrib['timestamp'] <= end)
 
     def test_invalid_range(self):
         """Test the site.usercontribs() method with invalid parameters."""

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d47a1884c7bd154b4d5b3b7666ce1345879efb8
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to