jenkins-bot has submitted this change and it was merged.
Change subject: Revert "(bug 58943) Archivebot: create unit tests for Timestripper"
......................................................................
Revert "(bug 58943) Archivebot: create unit tests for Timestripper"
Still a deadlock on Travis CI, even though it worked
for me locally...
This reverts commit 7393a66e1f31156b1ab8cd0cf5ceb274bf8bc027.
Change-Id: Id129e5219a9103498f06996c3462c9c6fc919487
---
D tests/timestripper_tests.py
1 file changed, 0 insertions(+), 72 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/timestripper_tests.py b/tests/timestripper_tests.py
deleted file mode 100644
index 12e0ff9..0000000
--- a/tests/timestripper_tests.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests for archivebot.py/Timestripper.
-"""
-#
-# (C) Pywikipedia bot team, 2014
-#
-# Distributed under the terms of the MIT license.
-#
-__version__ = '$Id$'
-
-
-import pywikibot
-from utils import PywikibotTestCase, unittest
-import scripts.archivebot as ab
-import re
-import datetime
-
-
-class TestTimeStripper(unittest.TestCase):
- """Test cases for Link objects"""
-
- def setUp(self):
- site = pywikibot.Site('fr', 'wikipedia')
- self.months = ab.Months(site=site)
- self.months.updateMonths(site=site)
- self.ts = ab.TimeStripper()
-
- def test_findmarker(self):
- """Test that string which is not part of text is found"""
-
- txt = u'this is a string with a maker is @@@@already present'
- self.assertEqual(self.ts.findmarker(txt, base=u'@@', delta='@@'),
- '@@@@@@')
-
- def test_last_match_and_replace(self):
- """Test that pattern matches the righmost item"""
-
- txtWithMatch = u'this string has one 1998, 1999 and 3000 in it'
- txtWithNoMatch = u'this string has no match'
- pat = self.ts.yearR
-
- self.assertEqual(self.ts.last_match_and_replace(txtWithMatch, pat),
- (u'this string has one @@, @@ and 3000 in it',
- {'year': u'1999'})
- )
- self.assertEqual(self.ts.last_match_and_replace(txtWithNoMatch, pat),
- (txtWithNoMatch,
- None)
- )
-
- def test_timestripper(self):
- """Test that correct date is matched"""
-
- txtMatch = u'3 février 2010 à 19:48 (CET) 7 février 2010 à 19:48 (CET)'
- txtNoMatch = u'3 March 2010 19:48 (CET) 7 March 2010 19:48 (CET)'
-
- res = datetime.datetime(2010, 2, 7, 19, 48,
- tzinfo=ab.tzoneFixedOffset(60, 'Europe/Paris'))
-
- self.assertEqual(self.ts.timestripper(txtMatch), res)
- self.assertEqual(self.ts.timestripper(txtNoMatch), None)
-
-
-if __name__ == '__main__':
- try:
- try:
- unittest.main()
- except SystemExit:
- pass
- finally:
- pywikibot.stopme()
--
To view, visit https://gerrit.wikimedia.org/r/109466
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id129e5219a9103498f06996c3462c9c6fc919487
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: (bug 55193) Missing key in ['query-continue'] value
......................................................................
(bug 55193) Missing key in ['query-continue'] value
Handling of multiple query-continue values.
https://bugzilla.wikimedia.org/show_bug.cgi?id=55193
Change-Id: I3941fca0daef38221f7ffe04e034c11cdaf6fe17
---
M pywikibot/data/api.py
1 file changed, 20 insertions(+), 11 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 043cc52..1dbd5ac 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -525,9 +525,16 @@
self.resultkey = "pages" # name of the "query" subelement key
else: # to look for when iterating
self.resultkey = self.module
- self.continuekey = self.module # usually the query-continue key
- # is the same as the querymodule,
- # but not always
+
+ # usually the query-continue key is the same as the querymodule,
+ # but not always
+ # API can return more than one query-continue key, if multiple properties
+ # are requested by the query, e.g.
+ # "query-continue":{
+ # "langlinks":{"llcontinue":"12188973|pt"},
+ # "templates":{"tlcontinue":"310820|828|Namespace_detect"}}
+ # self.continuekey is a list
+ self.continuekey = self.module.split('|')
@property
def __modules(self):
@@ -720,17 +727,19 @@
continue
if not "query-continue" in self.data:
return
- if not self.continuekey in self.data["query-continue"]:
+ if all(key not in self.data["query-continue"] for key in self.continuekey):
pywikibot.log(
- u"Missing '%s' key in ['query-continue'] value."
+ u"Missing '%s' key(s) in ['query-continue'] value."
% self.continuekey)
return
- update = self.data["query-continue"][self.continuekey]
- for key, value in update.items():
- # query-continue can return ints
- if isinstance(value, int):
- value = str(value)
- self.request[key] = value
+ query_continue_pairs = self.data["query-continue"].values()
+ for query_continue_pair in query_continue_pairs:
+ for key, value in query_continue_pair.items():
+ # query-continue can return ints
+ if isinstance(value, int):
+ value = str(value)
+ self.request[key] = value
+
del self.data # a new request with query-continue is needed
def result(self, data):
--
To view, visit https://gerrit.wikimedia.org/r/105975
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3941fca0daef38221f7ffe04e034c11cdaf6fe17
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Yurik <yurik(a)wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>