```
=================================== 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&meta=userinfo|wikibase&uiprop=blockinfo|hasmsg&rawcontinue=&maxlag=15:
```
{
"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='https://wikidata.beta.wmflabs.org/w/index.php')
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='https://www.wikidata.org/w/index.php')
```
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 does not make sense, we probably should create a new family file for `wikidata.beta`. At the same time, items on wikidata.beta.wmflabs.org cannot be connected to beta wikis, see {T124715} and therefore such a family file will be mostly useless.
I'm just going to ignore the other warning for now.