| Dalba created this task. Dalba added projects: Pywikibot-core, Pywikibot-tests. Herald added subscribers: pywikibot-bugs-list, Aklapper. |
TASK DESCRIPTION
=================================== FAILURES ===================================
____ TestGetSDTemplateNoSysop.test_with_delete_and_non_existing_sdtemplate _____
self = <tests.redirect_bot_tests.TestGetSDTemplateNoSysop testMethod=test_with_delete_and_non_existing_sdtemplate>
def test_with_delete_and_non_existing_sdtemplate(self):
"""Test with delete and non-exisitng sdtemplate."""
options = {'delete': True, 'sdtemplate': 'txt {{n|a}} txt'}
with patch.object(Page, 'exists', new=Mock(return_value=False)):
with patch.object(pywikibot, 'warning') as w:
bot = RedirectRobot('broken', None, **options)
> w.assert_called_once_with('No speedy deletion template "n" available.')
tests/redirect_bot_tests.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_mock_self = <MagicMock name='warning' id='139843452598984'>
args = ('No speedy deletion template "n" available.',), kwargs = {}
self = <MagicMock name='warning' id='139843452598984'>
msg = "Expected 'warning' to be called once. Called 2 times."
def assert_called_once_with(_mock_self, *args, **kwargs):
"""assert that the mock was called exactly once and with the specified
arguments."""
self = _mock_self
if not self.call_count == 1:
msg = ("Expected '%s' to be called once. Called %s times." %
(self._mock_name or 'mock', self.call_count))
> raise AssertionError(msg)
E AssertionError: Expected 'warning' to be called once. Called 2 times.
/opt/python/3.4.2/lib/python3.4/unittest/mock.py:781: AssertionError
___________ TestGetSDTemplateNoSysop.test_with_delete_no_sd_no_i18n ____________
self = <tests.redirect_bot_tests.TestGetSDTemplateNoSysop testMethod=test_with_delete_no_sd_no_i18n>
@patch.object(i18n, 'twhas_key', new=Mock(return_value=False))
def test_with_delete_no_sd_no_i18n(self):
"""Test with delete and no i18n template."""
with patch.object(pywikibot, 'warning') as w:
bot = RedirectRobot('broken', None, delete=True)
> w.assert_called_once_with('No speedy deletion template available.')
tests/redirect_bot_tests.py:51:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_mock_self = <MagicMock name='warning' id='139843452635624'>
args = ('No speedy deletion template available.',), kwargs = {}
self = <MagicMock name='warning' id='139843452635624'>
msg = "Expected 'warning' to be called once. Called 2 times."
def assert_called_once_with(_mock_self, *args, **kwargs):
"""assert that the mock was called exactly once and with the specified
arguments."""
self = _mock_self
if not self.call_count == 1:
msg = ("Expected '%s' to be called once. Called %s times." %
(self._mock_name or 'mock', self.call_count))
> raise AssertionError(msg)
E AssertionError: Expected 'warning' to be called once. Called 2 times.The extra warning is:
WARNING: Site "wsbeta:en" supports wikibase at "https://wikidata.beta.wmflabs.org/w/index.php", but creation failed: Unknown URL 'https://wikidata.beta.wmflabs.org/w/index.php'..
It's due to calling of site.data_repository() method.
According to https://en.wikisource.beta.wmflabs.org/w/api.php?action="">:
{
"query": {
"userinfo": {
"id": 383,
"name": "Dalba"
},
"wikibase": {
"repo": {
"url": {
"base": "https://wikidata.beta.wmflabs.org",
"scriptpath": "/w",
"articlepath": "/wiki/$1"
}
},
"siteid": "enwikisource"
}
}The https://wikidata.beta.wmflabs.org URL is correct and working.
So why the following call fails?
Site(interface='DataSite', url=""
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "G:\programming\python\wiki\pywikibot-core\pywikibot\__init__.py", line 877, in Site
raise SiteDefinitionError("Unknown URL '{0}'.".format(url))
pywikibot.exceptions.SiteDefinitionError: Unknown URL 'https://wikidata.beta.wmflabs.org/w/index.php'.The same call for production URL works fine.
Site(interface='DataSite', url="">
Adding the URL to wikidata_family.py seems to fix the issue:
self.langs = {
'wikidata': 'www.wikidata.org',
'test': 'test.wikidata.org',
'wikidata.beta': 'wikidata.beta.wmflabs.org',
}But it raises another warning:
WARNING: ...pywikibot-core\pywikibot\family.py:964: FamilyMaintenanceWarning: Family wikidata code wikidata.beta contains non-ascii characters
I think we can allow dots as part of family code to resolve this.
TASK DETAIL
EMAIL PREFERENCES
To: Dalba
Cc: Aklapper, pywikibot-bugs-list, Dalba, Magul, Tbscho, MayS, Mdupont, JJMC89, Avicennasis, Sn1per, jayvdb, Masti, Alchimista, Rxy
Cc: Aklapper, pywikibot-bugs-list, Dalba, Magul, Tbscho, MayS, Mdupont, JJMC89, Avicennasis, Sn1per, jayvdb, Masti, Alchimista, Rxy
_______________________________________________ pywikibot-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs
