jenkins-bot has submitted this change and it was merged.
Change subject: Wikibase integration tests fail on test.wikipedia
......................................................................
Wikibase integration tests fail on test.wikipedia
5d25a341 introduced tests for the UnconnectedPages
generator introduced in dff802ba.
Unfortunately these tests can not be run on test.wikipedia
as it isn't configured correctly.
Bug: T85358
Change-Id: Idf5f2042448776eda206ad825d69809f698acfd1
---
M tests/pagegenerators_tests.py
M tests/site_tests.py
2 files changed, 4 insertions(+), 0 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index ce51bfc..cdcdb05 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -914,6 +914,8 @@
"""Test that the ItemPage returned raises NoPage."""
if not self.site.data_repository():
raise unittest.SkipTest('Site is not using a Wikibase repository')
+ if self.site.hostname() == 'test.wikipedia.org':
+ raise unittest.SkipTest('test.wikipedia is misconfigured; T85358')
cnt = 0
for page in pagegenerators.UnconnectedPageGenerator(self.site, total=5):
self.assertRaises(pywikibot.NoPage, pywikibot.ItemPage.fromPage,
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 5946d3d..444c3e0 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -818,6 +818,8 @@
"""Test that the ItemPage returned raises NoPage."""
if not self.site.data_repository():
raise unittest.SkipTest('Site is not using a Wikibase repository')
+ if self.site.hostname() == 'test.wikipedia.org':
+ raise unittest.SkipTest('test.wikipedia is misconfigured; T85358')
cnt = 0
for page in self.site.unconnected_pages(total=5):
self.assertRaises(pywikibot.NoPage, pywikibot.ItemPage.fromPage,
--
To view, visit https://gerrit.wikimedia.org/r/231764
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idf5f2042448776eda206ad825d69809f698acfd1
Gerrit-PatchSet: 4
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 <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Check older status in unconnected tests
......................................................................
[FIX] Check older status in unconnected tests
When an unconnected page gets connected it may still be reported as
unconnected. This is now getting the revision 5 minutes ago and verifying that
the site is not already linked then.
Change-Id: I0831be6e3a541204610a03bfd07b442930555fd8
---
M tests/pagegenerators_tests.py
M tests/site_tests.py
2 files changed, 38 insertions(+), 6 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index ce51bfc..7aa4e12 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -11,6 +11,7 @@
import calendar
import datetime
+import json
import os
import sys
@@ -915,9 +916,24 @@
if not self.site.data_repository():
raise unittest.SkipTest('Site is not using a Wikibase repository')
cnt = 0
- for page in pagegenerators.UnconnectedPageGenerator(self.site, total=5):
- self.assertRaises(pywikibot.NoPage, pywikibot.ItemPage.fromPage,
- page)
+ start_time = datetime.datetime.now() - datetime.timedelta(minutes=5)
+ # Pages which have been connected recently may still be reported as
+ # unconnected. So try on an version that is a few minutes older if the
+ # tested site appears as a sitelink.
+ for page in self.site.unconnected_pages(total=5):
+ try:
+ item = pywikibot.ItemPage.fromPage(page)
+ except pywikibot.NoPage:
+ pass
+ else:
+ revisions = list(item.revisions(total=1, starttime=start_time,
+ content=True))
+ if revisions:
+ sitelinks = json.loads(revisions[0].text)['sitelinks']
+ self.assertNotIn(
+ self.site.dbName(), sitelinks,
+ 'Page "{0}" is connected to a Wikibase '
+ 'repository'.format(page.title()))
cnt += 1
self.assertLessEqual(cnt, 5)
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 5946d3d..fb75c7b 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -10,10 +10,11 @@
__version__ = '$Id$'
+import json
import sys
import os
from collections import Iterable, Mapping
-from datetime import datetime
+from datetime import datetime, timedelta
import re
import pywikibot
@@ -819,9 +820,24 @@
if not self.site.data_repository():
raise unittest.SkipTest('Site is not using a Wikibase repository')
cnt = 0
+ start_time = datetime.now() - timedelta(minutes=5)
+ # Pages which have been connected recently may still be reported as
+ # unconnected. So try on an version that is a few minutes older if the
+ # tested site appears as a sitelink.
for page in self.site.unconnected_pages(total=5):
- self.assertRaises(pywikibot.NoPage, pywikibot.ItemPage.fromPage,
- page)
+ try:
+ item = pywikibot.ItemPage.fromPage(page)
+ except pywikibot.NoPage:
+ pass
+ else:
+ revisions = list(item.revisions(total=1, starttime=start_time,
+ content=True))
+ if revisions:
+ sitelinks = json.loads(revisions[0].text)['sitelinks']
+ self.assertNotIn(
+ self.site.dbName(), sitelinks,
+ 'Page "{0}" is connected to a Wikibase '
+ 'repository'.format(page.title()))
cnt += 1
self.assertLessEqual(cnt, 5)
--
To view, visit https://gerrit.wikimedia.org/r/231774
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0831be6e3a541204610a03bfd07b442930555fd8
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
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 <>
jenkins-bot has submitted this change and it was merged.
Change subject: Revert "Revert "[FIX] ParamInfo: Correctly initialize ParamInfo""
......................................................................
Revert "Revert "[FIX] ParamInfo: Correctly initialize ParamInfo""
This reverts commit e184e8556d29b9a4e69fafb3694db617a5b84ba4.
Change-Id: Ie45b1fa024a43f65a9ec8028f2ee194f7a96c470
---
M pywikibot/data/api.py
M tests/api_tests.py
2 files changed, 29 insertions(+), 7 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index c50e46d..a7b7f6d 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -551,13 +551,15 @@
# query modules can be prefixed with 'query+'
self._init()
- if 'query' in self._modules:
- # It does fetch() while initializing, and this method can't be
- # called before it's initialized.
- modules = self._normalize_modules(modules)
- elif self._action_modules:
- # At least we do know the valid action modules and require a subset
- assert not modules - self._action_modules - self.root_modules
+ if self._action_modules:
+ # The query module may be added before the action modules have been
+ if 'query' in self._modules:
+ # It does fetch() while initializing, and this method can't be
+ # called before it's initialized.
+ modules = self._normalize_modules(modules)
+ else:
+ # At least we do know the valid action modules and require a subset
+ assert not modules - self._action_modules - self.root_modules
self._fetch(modules)
diff --git a/tests/api_tests.py b/tests/api_tests.py
index 213cf3b..2a76405 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -163,6 +163,26 @@
self.assertIn('info', pi.query_modules)
self.assertIn('login', pi._action_modules)
+ def test_init_query_first(self):
+ """Test init where it first adds query and then main."""
+ def patched_generate_submodules(modules):
+ # Change the query such that query is handled before main
+ modules = set(modules)
+ if 'main' in modules:
+ assert 'query' in modules
+ modules.discard('main')
+ modules = list(modules) + ['main']
+ else:
+ assert 'query' not in modules
+ original_generate_submodules(modules)
+ pi = api.ParamInfo(self.site, set(['query', 'main']))
+ self.assertEqual(len(pi), 0)
+ original_generate_submodules = pi._generate_submodules
+ pi._generate_submodules = patched_generate_submodules
+ pi._init()
+ self.assertIn('main', pi._paraminfo)
+ self.assertIn('query', pi._paraminfo)
+
def test_init_pageset(self):
site = self.get_site()
self.assertNotIn('query', api.ParamInfo.init_modules)
--
To view, visit https://gerrit.wikimedia.org/r/231752
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie45b1fa024a43f65a9ec8028f2ee194f7a96c470
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Revert "[FIX] ParamInfo: Correctly initialize ParamInfo"
......................................................................
Revert "[FIX] ParamInfo: Correctly initialize ParamInfo"
This reverts commit 8f2fba2bf65947a849175c8ca95901cf15b9f4a2.
Bug: T109168
Change-Id: Ifc3f5fa492cda7f6b650a9cbab83b04cc98d7ea7
---
M pywikibot/data/api.py
M tests/api_tests.py
2 files changed, 7 insertions(+), 29 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index a7b7f6d..c50e46d 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -551,15 +551,13 @@
# query modules can be prefixed with 'query+'
self._init()
- if self._action_modules:
- # The query module may be added before the action modules have been
- if 'query' in self._modules:
- # It does fetch() while initializing, and this method can't be
- # called before it's initialized.
- modules = self._normalize_modules(modules)
- else:
- # At least we do know the valid action modules and require a subset
- assert not modules - self._action_modules - self.root_modules
+ if 'query' in self._modules:
+ # It does fetch() while initializing, and this method can't be
+ # called before it's initialized.
+ modules = self._normalize_modules(modules)
+ elif self._action_modules:
+ # At least we do know the valid action modules and require a subset
+ assert not modules - self._action_modules - self.root_modules
self._fetch(modules)
diff --git a/tests/api_tests.py b/tests/api_tests.py
index 2a76405..213cf3b 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -163,26 +163,6 @@
self.assertIn('info', pi.query_modules)
self.assertIn('login', pi._action_modules)
- def test_init_query_first(self):
- """Test init where it first adds query and then main."""
- def patched_generate_submodules(modules):
- # Change the query such that query is handled before main
- modules = set(modules)
- if 'main' in modules:
- assert 'query' in modules
- modules.discard('main')
- modules = list(modules) + ['main']
- else:
- assert 'query' not in modules
- original_generate_submodules(modules)
- pi = api.ParamInfo(self.site, set(['query', 'main']))
- self.assertEqual(len(pi), 0)
- original_generate_submodules = pi._generate_submodules
- pi._generate_submodules = patched_generate_submodules
- pi._init()
- self.assertIn('main', pi._paraminfo)
- self.assertIn('query', pi._paraminfo)
-
def test_init_pageset(self):
site = self.get_site()
self.assertNotIn('query', api.ParamInfo.init_modules)
--
To view, visit https://gerrit.wikimedia.org/r/231751
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifc3f5fa492cda7f6b650a9cbab83b04cc98d7ea7
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] site_detect_tests: Make output tabular
......................................................................
[IMPROV] site_detect_tests: Make output tabular
This adds whitespace at the end of the URL to make the width always the same
and easier to identify where the URL ends and the message begins.
Change-Id: I8e7cd26c0580cb750e358bfe46f5ab3b2f5a37b1
---
M tests/site_detect_tests.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_detect_tests.py b/tests/site_detect_tests.py
index d1a4bf5..bb3334d 100644
--- a/tests/site_detect_tests.py
+++ b/tests/site_detect_tests.py
@@ -62,8 +62,9 @@
sorted_all = sorted((norm(url) for url in self.all),
key=lambda item: item[0])
+ width = max(len(item[1]) for item in sorted_all)
print('Results:\n' + '\n'.join(
- '{0} {1} : {2}'.format(PREFIXES[i[0]], i[1], i[2])
+ '{0} {1:{3}} : {2}'.format(PREFIXES[i[0]], i[1], i[2], width)
for i in sorted_all))
def _wiki_detection(self, url, result):
--
To view, visit https://gerrit.wikimedia.org/r/231538
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8e7cd26c0580cb750e358bfe46f5ab3b2f5a37b1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] ParamInfo: Correctly initialize ParamInfo
......................................................................
[FIX] ParamInfo: Correctly initialize ParamInfo
The ParamInfo can do some sanity checking but that is not possible when the
base modules aren't loaded yet. The 424eaa35 change assumed that it would first
add the main modules and then the query modules. But in certain cases it first
added the query modules which let the class think it is properly initialized.
This could only happen when it loads the query modules together with the main
modules and even then could use the working ordering by chance.
Change-Id: I5fb97ba12acf7389c2ce37eff87e1aca432d397a
---
M pywikibot/data/api.py
M tests/api_tests.py
2 files changed, 29 insertions(+), 7 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index c50e46d..a7b7f6d 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -551,13 +551,15 @@
# query modules can be prefixed with 'query+'
self._init()
- if 'query' in self._modules:
- # It does fetch() while initializing, and this method can't be
- # called before it's initialized.
- modules = self._normalize_modules(modules)
- elif self._action_modules:
- # At least we do know the valid action modules and require a subset
- assert not modules - self._action_modules - self.root_modules
+ if self._action_modules:
+ # The query module may be added before the action modules have been
+ if 'query' in self._modules:
+ # It does fetch() while initializing, and this method can't be
+ # called before it's initialized.
+ modules = self._normalize_modules(modules)
+ else:
+ # At least we do know the valid action modules and require a subset
+ assert not modules - self._action_modules - self.root_modules
self._fetch(modules)
diff --git a/tests/api_tests.py b/tests/api_tests.py
index 213cf3b..2a76405 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -163,6 +163,26 @@
self.assertIn('info', pi.query_modules)
self.assertIn('login', pi._action_modules)
+ def test_init_query_first(self):
+ """Test init where it first adds query and then main."""
+ def patched_generate_submodules(modules):
+ # Change the query such that query is handled before main
+ modules = set(modules)
+ if 'main' in modules:
+ assert 'query' in modules
+ modules.discard('main')
+ modules = list(modules) + ['main']
+ else:
+ assert 'query' not in modules
+ original_generate_submodules(modules)
+ pi = api.ParamInfo(self.site, set(['query', 'main']))
+ self.assertEqual(len(pi), 0)
+ original_generate_submodules = pi._generate_submodules
+ pi._generate_submodules = patched_generate_submodules
+ pi._init()
+ self.assertIn('main', pi._paraminfo)
+ self.assertIn('query', pi._paraminfo)
+
def test_init_pageset(self):
site = self.get_site()
self.assertNotIn('query', api.ParamInfo.init_modules)
--
To view, visit https://gerrit.wikimedia.org/r/231594
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5fb97ba12acf7389c2ce37eff87e1aca432d397a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
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 <>