jenkins-bot has submitted this change and it was merged.
Change subject: Add tests for weblib ......................................................................
Add tests for weblib
Change-Id: I417d488ebebc39d05a4ce533b1bbf787801d69b0 --- A tests/weblib_tests.py 1 file changed, 38 insertions(+), 0 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/weblib_tests.py b/tests/weblib_tests.py new file mode 100644 index 0000000..08c4804 --- /dev/null +++ b/tests/weblib_tests.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# +# (C) Pywikipedia bot team, 2014 +# +# Distributed under the terms of the MIT license. +# +__version__ = '$Id$' + +from urlparse import urlparse +import pywikibot.weblib as weblib +from utils import unittest + + +class TestArchiveSites(unittest.TestCase): + def testInternetArchiveNewest(self): + archivedversion = weblib.getInternetArchiveURL('http://google.com') + parsed = urlparse(archivedversion) + self.assertIn(parsed.scheme, [u'http', u'https']) + self.assertEqual(parsed.netloc, u'web.archive.org') + self.assertTrue(parsed.path.endswith('www.google.com/')) + + def testInternetArchiveOlder(self): + archivedversion = weblib.getInternetArchiveURL('http://google.com', '200606') + parsed = urlparse(archivedversion) + self.assertIn(parsed.scheme, [u'http', u'https']) + self.assertEqual(parsed.netloc, u'web.archive.org') + self.assertTrue(parsed.path.endswith('www.google.com/')) + self.assertIn('200606', parsed.path) + + def testWebCiteOlder(self): + archivedversion = weblib.getWebCitationURL('http://google.com', '20130101') + self.assertEqual(archivedversion, 'http://www.webcitation.org/6DHSeh2L0') + +if __name__ == '__main__': + try: + unittest.main() + except SystemExit: + pass
pywikibot-commits@lists.wikimedia.org