2005-12-07 21:55:16 +00:00
|
|
|
|
# -*- coding: iso-8859-1 -*-
|
2010-03-05 11:49:54 +00:00
|
|
|
|
# Copyright (C) 2004-2010 Bastian Kleineidam
|
2005-12-07 21:55:16 +00:00
|
|
|
|
#
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
#
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
#
|
2009-07-24 21:58:20 +00:00
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-12-07 21:55:16 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Test error checking.
|
|
|
|
|
|
"""
|
2008-05-20 17:01:16 +00:00
|
|
|
|
from . import LinkCheckTest
|
2005-12-07 21:55:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
2008-05-20 17:01:16 +00:00
|
|
|
|
class TestError (LinkCheckTest):
|
2005-12-07 21:55:16 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Test unrecognized or syntactically wrong links.
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def test_unrecognized (self):
|
2009-06-26 05:20:21 +00:00
|
|
|
|
# Unrecognized scheme
|
2005-12-07 21:55:16 +00:00
|
|
|
|
url = u"hutzli:"
|
2007-11-28 18:46:50 +00:00
|
|
|
|
attrs = self.get_attrs(url=url)
|
|
|
|
|
|
attrs['nurl'] = self.norm("file://%(curdir)s/%(url)s" % attrs)
|
2005-12-07 21:55:16 +00:00
|
|
|
|
resultlines = [
|
2010-02-22 00:06:19 +00:00
|
|
|
|
u"url file://%(curdir)s/%(url)s" % attrs,
|
2007-11-28 18:46:50 +00:00
|
|
|
|
u"cache key %(nurl)s" % attrs,
|
|
|
|
|
|
u"real url %(nurl)s" % attrs,
|
2005-12-07 21:55:16 +00:00
|
|
|
|
u"error",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
|
|
|
|
|
|
|
|
|
|
|
def test_leading_whitespace (self):
|
2009-06-26 05:20:21 +00:00
|
|
|
|
# Leading whitespace
|
2005-12-07 21:55:16 +00:00
|
|
|
|
url = u" http://www.heise.de/"
|
2007-11-28 18:46:50 +00:00
|
|
|
|
attrs = self.get_attrs(url=url)
|
|
|
|
|
|
attrs['nurl'] = self.norm("file://%(curdir)s/%(url)s" % attrs)
|
2005-12-07 21:55:16 +00:00
|
|
|
|
resultlines = [
|
2010-02-22 00:06:19 +00:00
|
|
|
|
u"url file://%(curdir)s/%(url)s" % attrs,
|
2007-11-28 18:46:50 +00:00
|
|
|
|
u"cache key %(nurl)s" % attrs,
|
|
|
|
|
|
u"real url %(nurl)s" % attrs,
|
2009-02-23 19:08:06 +00:00
|
|
|
|
u"name %(url)s" % attrs,
|
2005-12-07 21:55:16 +00:00
|
|
|
|
u"error",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
|
|
|
|
|
url = u"\nhttp://www.heise.de/"
|
2007-11-28 18:46:50 +00:00
|
|
|
|
attrs = self.get_attrs(url=url)
|
|
|
|
|
|
attrs['nurl'] = self.norm("file://%(curdir)s/%(url)s" % attrs)
|
2005-12-07 21:55:16 +00:00
|
|
|
|
resultlines = [
|
2010-02-22 00:06:19 +00:00
|
|
|
|
u"url file://%(curdir)s/%(url)s" % attrs,
|
2007-11-28 18:46:50 +00:00
|
|
|
|
u"cache key %(nurl)s" % attrs,
|
|
|
|
|
|
u"real url %(nurl)s" % attrs,
|
2009-02-23 19:08:06 +00:00
|
|
|
|
u"name %(url)s" % attrs,
|
2005-12-07 21:55:16 +00:00
|
|
|
|
u"error",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
|
|
|
|
|
|
|
|
|
|
|
def test_trailing_whitespace (self):
|
2009-06-26 05:20:21 +00:00
|
|
|
|
# Trailing whitespace
|
2005-12-07 21:55:16 +00:00
|
|
|
|
url = u"http://www.heise.de/ "
|
|
|
|
|
|
nurl = self.norm(url)
|
|
|
|
|
|
resultlines = [
|
|
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % nurl,
|
|
|
|
|
|
u"real url %s" % nurl,
|
|
|
|
|
|
u"error",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
|
|
|
|
|
url = u"http://www.heise.de/\n"
|
|
|
|
|
|
nurl = self.norm(url)
|
|
|
|
|
|
resultlines = [
|
|
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % nurl,
|
|
|
|
|
|
u"real url %s" % nurl,
|
|
|
|
|
|
u"error",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
|
|
|
|
|
|
2006-05-13 13:41:10 +00:00
|
|
|
|
def test_invalid1 (self):
|
2005-12-07 21:55:16 +00:00
|
|
|
|
# invalid scheme chars
|
|
|
|
|
|
url = u"<EFBFBD><EFBFBD><EFBFBD>?:"
|
2007-11-28 18:46:50 +00:00
|
|
|
|
attrs = self.get_attrs(url=url)
|
|
|
|
|
|
attrs['nurl'] = self.norm("file://%(curdir)s/%(url)s" % attrs)
|
2005-12-07 21:55:16 +00:00
|
|
|
|
resultlines = [
|
2010-02-22 00:06:19 +00:00
|
|
|
|
u"url file://%(curdir)s/%(url)s" % attrs,
|
2007-11-28 18:46:50 +00:00
|
|
|
|
u"cache key %(nurl)s" % attrs,
|
|
|
|
|
|
u"real url %(nurl)s" % attrs,
|
2009-02-23 19:08:06 +00:00
|
|
|
|
u"name %(url)s" % attrs,
|
2005-12-07 21:55:16 +00:00
|
|
|
|
u"error",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
2006-05-13 13:41:10 +00:00
|
|
|
|
|
|
|
|
|
|
def test_invalid2 (self):
|
2005-12-07 21:55:16 +00:00
|
|
|
|
# missing scheme alltogether
|
|
|
|
|
|
url = u"?<3F><><EFBFBD>?"
|
2007-11-28 18:46:50 +00:00
|
|
|
|
attrs = self.get_attrs(url=url)
|
|
|
|
|
|
attrs['nurl'] = self.norm("file://%(curdir)s/%(url)s" % attrs)
|
2005-12-07 21:55:16 +00:00
|
|
|
|
resultlines = [
|
2010-02-22 00:06:19 +00:00
|
|
|
|
u"url file://%(curdir)s/%(url)s" % attrs,
|
2007-11-28 18:46:50 +00:00
|
|
|
|
u"cache key %(nurl)s" % attrs,
|
|
|
|
|
|
u"real url %(nurl)s" % attrs,
|
2009-02-23 19:08:06 +00:00
|
|
|
|
u"name %(url)s" % attrs,
|
2005-12-07 21:55:16 +00:00
|
|
|
|
u"error",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
2006-05-13 13:41:10 +00:00
|
|
|
|
|
|
|
|
|
|
def test_invalid3 (self):
|
2005-12-07 21:55:16 +00:00
|
|
|
|
# really fucked up
|
|
|
|
|
|
url = u"@<40><><EFBFBD>][<5B> <20>@] <20><>"
|
2007-11-28 18:46:50 +00:00
|
|
|
|
attrs = self.get_attrs(url=url)
|
|
|
|
|
|
attrs['nurl'] = self.norm("file://%(curdir)s/%(url)s" % attrs)
|
2005-12-07 21:55:16 +00:00
|
|
|
|
resultlines = [
|
2010-02-22 00:06:19 +00:00
|
|
|
|
u"url file://%(curdir)s/%(url)s" % attrs,
|
2007-11-28 18:46:50 +00:00
|
|
|
|
u"cache key %(nurl)s" % attrs,
|
|
|
|
|
|
u"real url %(nurl)s" % attrs,
|
2009-02-23 19:08:06 +00:00
|
|
|
|
u"name %(url)s" % attrs,
|
2005-12-07 21:55:16 +00:00
|
|
|
|
u"error",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|