jenkins-bot merged this change.
[cleanup] Remove weblib tests
weblib methods are deprecated for 4 years in favour of memento_client
library due to T85001. The weblib function for WebCite and the
Internet Archive function are broken. All tests are failing or skipped.
- deprecate weblib as a whole
- remove weblib_tests.py
- remove weblib_test inside weblinkchecker_tests.py
Bug: T85001
Change-Id: Ibb04c856b55d7604248b26572f02b04389b3c001
---
M pywikibot/weblib.py
M scripts/weblinkchecker.py
M tests/__init__.py
D tests/weblib_tests.py
M tests/weblinkchecker_tests.py
5 files changed, 6 insertions(+), 126 deletions(-)
diff --git a/pywikibot/weblib.py b/pywikibot/weblib.py
index 988c946..7d83592 100644
--- a/pywikibot/weblib.py
+++ b/pywikibot/weblib.py
@@ -15,15 +15,18 @@
from pywikibot.comms import http
from pywikibot import config2
-from pywikibot.tools import deprecated, PY2
+from pywikibot.tools import issue_deprecation_warning, PY2
if not PY2:
from urllib.parse import urlencode
else:
from urllib import urlencode
+issue_deprecation_warning(
+ 'weblib', 'memento_client package', since='20150811',
+ warning_class=FutureWarning)
-@deprecated('memento_client package', since='20150811', future_warning=True)
+
def getInternetArchiveURL(url, timestamp=None):
"""Return archived URL by Internet Archive.
@@ -63,7 +66,6 @@
return None
-@deprecated('memento_client package', since='20150811', future_warning=True)
def getWebCitationURL(url, timestamp=None):
"""Return archived URL by Web Citation.
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index 958f0d1..f5f6977 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -132,7 +132,7 @@
import pywikibot
from pywikibot import (
- comms, i18n, config, pagegenerators, textlib, weblib, config2,
+ comms, i18n, config, pagegenerators, textlib, config2,
)
from pywikibot.bot import ExistingPageBot, SingleSiteBot, suggest_help
@@ -725,10 +725,6 @@
'get_closest_memento_url({0}) failed: {1}'.format(
url, e))
archiveURL = None
- if archiveURL is None:
- archiveURL = weblib.getInternetArchiveURL(url)
- if archiveURL is None:
- archiveURL = weblib.getWebCitationURL(url)
self.log(url, error, page, archiveURL)
else:
self.historyDict[url] = [(page.title(), now, error)]
diff --git a/tests/__init__.py b/tests/__init__.py
index 1dca767..2c67e84 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -113,7 +113,6 @@
'pagegenerators',
'cosmetic_changes',
'wikistats',
- 'weblib',
'i18n',
'tk',
'wikibase',
diff --git a/tests/weblib_tests.py b/tests/weblib_tests.py
deleted file mode 100644
index 98d657b..0000000
--- a/tests/weblib_tests.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# -*- coding: utf-8 -*-
-"""Weblib test module."""
-#
-# (C) Pywikibot team, 2014-2018
-#
-# Distributed under the terms of the MIT license.
-#
-from __future__ import absolute_import, division, unicode_literals
-
-from requests.exceptions import ConnectionError as RequestsConnectionError
-
-from pywikibot.tools import PY2
-import pywikibot.weblib as weblib
-from tests.aspects import unittest, DeprecationTestCase
-from tests.utils import PatchedHttp
-
-if not PY2:
- from urllib.parse import urlparse
-else:
- from urlparse import urlparse
-
-
-class TestInternetArchive(DeprecationTestCase):
-
- """Test weblib methods to access Internet Archive."""
-
- sites = {
- 'archive.org': {
- 'hostname': 'https://archive.org/wayback/available?url=invalid',
- },
- }
-
- def _test_response(self, response, *args, **kwargs):
- # for later tests this is must be present, and it'll tell us the
- # original content if that does not match
- self.assertIn('closest', response.text)
-
- def _get_archive_url(self, url, date_string=None):
- with PatchedHttp(weblib, False) as p:
- p.after_fetch = self._test_response
- try:
- archivedversion = weblib.getInternetArchiveURL(
- url, date_string)
- except RequestsConnectionError as e:
- self.skipTest(e)
- self.assertOneDeprecation()
- return archivedversion
-
- def testInternetArchiveNewest(self):
- """Test Internet Archive for newest https://google.com."""
- archivedversion = self._get_archive_url('https://google.com')
- parsed = urlparse(archivedversion)
- self.assertIn(parsed.scheme, ['http', 'https'])
- self.assertEqual(parsed.netloc, 'web.archive.org')
- self.assertTrue(parsed.path.strip('/').endswith('google.com'),
- parsed.path)
-
- def testInternetArchiveOlder(self):
- """Test Internet Archive for https://google.com as of June 2006."""
- archivedversion = self._get_archive_url('https://google.com',
- '20060601')
- parsed = urlparse(archivedversion)
- self.assertIn(parsed.scheme, ['http', 'https'])
- self.assertEqual(parsed.netloc, 'web.archive.org')
- self.assertTrue(parsed.path.strip('/').endswith('google.com'),
- parsed.path)
- self.assertIn('200606', parsed.path)
-
-
-class TestWebCite(DeprecationTestCase):
-
- """Test weblib methods to access WebCite."""
-
- sites = {
- 'webcite': {
- 'hostname': 'www.webcitation.org',
- }
- }
-
- def _get_archive_url(self, url, date_string=None):
- archivedversion = weblib.getWebCitationURL(url, date_string)
- self.assertOneDeprecation()
- return archivedversion
-
- @unittest.expectedFailure # See T110640
- def testWebCiteOlder(self):
- """Test WebCite for https://google.com as of January 2013."""
- archivedversion = self._get_archive_url('https://google.com',
- '20130101')
- self.assertEqual(archivedversion,
- 'http://www.webcitation.org/6DHSeh2L0')
-
-
-if __name__ == '__main__': # pragma: no cover
- try:
- unittest.main()
- except SystemExit:
- pass
diff --git a/tests/weblinkchecker_tests.py b/tests/weblinkchecker_tests.py
index 4608723..53440f6 100644
--- a/tests/weblinkchecker_tests.py
+++ b/tests/weblinkchecker_tests.py
@@ -14,7 +14,6 @@
from pywikibot.tools import PY2
from scripts import weblinkchecker
from tests.aspects import unittest, require_modules, TestCase
-from tests import weblib_tests
if not PY2:
from urllib.parse import urlparse
@@ -42,24 +41,6 @@
self.skipTest(e)
-class WeblibTestMementoInternetArchive(MementoTestCase,
- weblib_tests.TestInternetArchive):
-
- """Test InternetArchive Memento using old weblib tests."""
-
- timegate_uri = 'http://web.archive.org/web/'
- hostname = timegate_uri
-
-
-class WeblibTestMementoWebCite(MementoTestCase, weblib_tests.TestWebCite):
-
- """Test WebCite Memento using old weblib tests."""
-
- timegate_uri = 'http://timetravel.mementoweb.org/webcite/timegate/'
- hostname = ('http://timetravel.mementoweb.org/webcite/'
- 'timemap/json/http://google.com')
-
-
class TestMementoWebCite(MementoTestCase):
"""New WebCite Memento tests."""
To view, visit change 526522. To unsubscribe, or for help writing mail filters, visit settings.