mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-05 13:14:46 +00:00
moved
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2950 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
ddb09ab76a
commit
98e3e26644
47 changed files with 0 additions and 2092 deletions
|
|
@ -1,193 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Define standard test support classes funtional for LinkChecker tests.
|
||||
"""
|
||||
|
||||
import os
|
||||
import codecs
|
||||
import unittest
|
||||
import difflib
|
||||
|
||||
import linkcheck
|
||||
import linkcheck.checker
|
||||
import linkcheck.checker.cache
|
||||
import linkcheck.checker.consumer
|
||||
import linkcheck.configuration
|
||||
import linkcheck.logger
|
||||
|
||||
|
||||
class TestLogger (linkcheck.logger.Logger):
|
||||
"""
|
||||
Output logger for automatic regression tests.
|
||||
"""
|
||||
|
||||
def __init__ (self, **kwargs):
|
||||
"""
|
||||
The kwargs must have "expected" keyword with the expected logger
|
||||
output lines.
|
||||
"""
|
||||
super(TestLogger, self).__init__(**kwargs)
|
||||
# list of expected output lines
|
||||
self.expected = kwargs['expected']
|
||||
# list of real output lines
|
||||
self.result = []
|
||||
# diff between expected and real output
|
||||
self.diff = []
|
||||
|
||||
def start_output (self):
|
||||
"""
|
||||
Nothing to do here.
|
||||
"""
|
||||
pass
|
||||
|
||||
def log_url (self, url_data):
|
||||
"""
|
||||
Append logger output to self.result.
|
||||
"""
|
||||
if self.has_part('url'):
|
||||
url = u"url %s" % (url_data.base_url or u"")
|
||||
if url_data.cached:
|
||||
url += u" (cached)"
|
||||
self.result.append(url)
|
||||
if self.has_part('cachekey'):
|
||||
self.result.append(u"cache key %s" % url_data.cache_url_key)
|
||||
if self.has_part('realurl'):
|
||||
self.result.append(u"real url %s" % url_data.url)
|
||||
if self.has_part('name') and url_data.name:
|
||||
self.result.append(u"name %s" % url_data.name)
|
||||
if self.has_part('base') and url_data.base_ref:
|
||||
self.result.append(u"baseurl %s" % url_data.base_ref)
|
||||
if self.has_part('info'):
|
||||
for info in url_data.info:
|
||||
self.result.append(u"info %s" % info)
|
||||
if self.has_part('warning'):
|
||||
for warning in url_data.warnings:
|
||||
self.result.append(u"warning %s" % warning[1])
|
||||
if self.has_part('result'):
|
||||
self.result.append(url_data.valid and u"valid" or u"error")
|
||||
# note: do not append url_data.result since this is
|
||||
# platform dependent
|
||||
|
||||
def end_output (self, linknumber=-1):
|
||||
"""
|
||||
Stores differences between expected and result in self.diff.
|
||||
"""
|
||||
for line in difflib.unified_diff(self.expected, self.result):
|
||||
if not isinstance(line, unicode):
|
||||
line = unicode(line, "iso8859-1", "ignore")
|
||||
self.diff.append(line)
|
||||
|
||||
|
||||
def get_test_consumer (confargs, logargs):
|
||||
"""
|
||||
Initialize a test configuration object.
|
||||
"""
|
||||
config = linkcheck.configuration.Configuration()
|
||||
config.logger_add('test', TestLogger)
|
||||
config['recursionlevel'] = 1
|
||||
config['logger'] = config.logger_new('test', **logargs)
|
||||
config["anchors"] = True
|
||||
config["verbose"] = True
|
||||
config['threads'] = 0
|
||||
config['geoip'] = None
|
||||
config.update(confargs)
|
||||
cache = linkcheck.checker.cache.Cache()
|
||||
return linkcheck.checker.consumer.Consumer(config, cache)
|
||||
|
||||
|
||||
class StandardTest (unittest.TestCase):
|
||||
"""
|
||||
Functional test class with ability to test local files.
|
||||
"""
|
||||
|
||||
def setUp (self):
|
||||
"""
|
||||
Check resources, using the provided function check_resources()
|
||||
from test.py.
|
||||
"""
|
||||
super(StandardTest, self).setUp()
|
||||
if hasattr(self, "needed_resources"):
|
||||
self.check_resources(self.needed_resources)
|
||||
|
||||
def norm (self, url):
|
||||
"""
|
||||
Helper function to norm a url.
|
||||
"""
|
||||
return linkcheck.url.url_norm(url)[0]
|
||||
|
||||
def get_file (self, filename):
|
||||
"""
|
||||
Get file name located within 'data' directory.
|
||||
"""
|
||||
return unicode(os.path.join("linkcheck", "ftests", "data", filename))
|
||||
|
||||
def get_resultlines (self, filename):
|
||||
"""
|
||||
Return contents of file, as list of lines without line endings,
|
||||
ignoring empty lines and lines starting with a hash sign (#).
|
||||
"""
|
||||
resultfile = self.get_file(filename+".result")
|
||||
d = {'curdir': os.getcwd()}
|
||||
f = codecs.open(resultfile, "r", "iso-8859-15")
|
||||
resultlines = [line.rstrip('\r\n') % d for line in f \
|
||||
if line.strip() and not line.startswith(u'#')]
|
||||
f.close()
|
||||
return resultlines
|
||||
|
||||
def file_test (self, filename, confargs=None, cmdline=True):
|
||||
"""
|
||||
Check <filename> with expected result in <filename>.result.
|
||||
"""
|
||||
url = self.get_file(filename)
|
||||
if confargs is None:
|
||||
confargs = {}
|
||||
logargs = {'expected': self.get_resultlines(filename)}
|
||||
consumer = get_test_consumer(confargs, logargs)
|
||||
url_data = linkcheck.checker.get_url_from(
|
||||
url, 0, consumer, cmdline=cmdline)
|
||||
consumer.append_url(url_data)
|
||||
linkcheck.checker.check_urls(consumer)
|
||||
if consumer.config('logger').diff:
|
||||
sep = unicode(os.linesep)
|
||||
l = [url] + consumer.config('logger').diff
|
||||
l = sep.join(l)
|
||||
self.fail(l.encode("iso8859-1", "ignore"))
|
||||
|
||||
def direct (self, url, resultlines, fields=None, recursionlevel=0,
|
||||
confargs=None, cmdline=False):
|
||||
"""
|
||||
Check url with expected result.
|
||||
"""
|
||||
assert isinstance(url, unicode), repr(url)
|
||||
if confargs is None:
|
||||
confargs = {'recursionlevel': recursionlevel}
|
||||
else:
|
||||
confargs['recursionlevel'] = recursionlevel
|
||||
logargs = {'expected': resultlines}
|
||||
if fields is not None:
|
||||
logargs['fields'] = fields
|
||||
consumer = get_test_consumer(confargs, logargs)
|
||||
url_data = linkcheck.checker.get_url_from(
|
||||
url, 0, consumer, cmdline=cmdline)
|
||||
consumer.append_url(url_data)
|
||||
linkcheck.checker.check_urls(consumer)
|
||||
if consumer.config('logger').diff:
|
||||
sep = unicode(os.linesep)
|
||||
l = [url] + consumer.config('logger').diff
|
||||
l = sep.join(l)
|
||||
self.fail(l.encode("iso8859-1", "ignore"))
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<a href="#myid">Bla</a>
|
||||
<ul>
|
||||
<li id="myid">
|
||||
</ul>
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/anchor.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/anchor.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/anchor.html
|
||||
valid
|
||||
|
||||
url #myid
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/anchor.html#myid
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/anchor.html
|
||||
name Bla
|
||||
valid
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<!-- base without href -->
|
||||
<base target="_top">
|
||||
<!-- meta url -->
|
||||
<META HTTP-equiv="refresh" content="0; url=base2.html">
|
||||
<!-- spaces between key and value -->
|
||||
<a href
|
||||
=
|
||||
"base2.html">
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/base1.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/base1.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/base1.html
|
||||
valid
|
||||
|
||||
url base2.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/base2.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/base2.html
|
||||
valid
|
||||
|
||||
url base2.html (cached)
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/base2.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/base2.html
|
||||
valid
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<!-- base with href -->
|
||||
<base href="base/">
|
||||
<a href="test.txt">
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/base2.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/base2.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/base2.html
|
||||
valid
|
||||
|
||||
url test.txt
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/base/test.txt
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/base/test.txt
|
||||
baseurl file://%(curdir)s/linkcheck/ftests/data/base/
|
||||
valid
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
<!-- codebase test -->
|
||||
<applet codebase="base/" archive="test.txt">
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/base3.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/base3.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/base3.html
|
||||
valid
|
||||
|
||||
url test.txt
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/base/test.txt
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/base/test.txt
|
||||
baseurl file://%(curdir)s/linkcheck/ftests/data/base/
|
||||
valid
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
|
||||
Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
|
||||
lang="en">
|
||||
<head>
|
||||
<base href="base/" />
|
||||
</head>
|
||||
<body>
|
||||
<a href="test.txt">Blubb</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/base4.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/base4.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/base4.html
|
||||
valid
|
||||
|
||||
url test.txt
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/base/test.txt
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/base/test.txt
|
||||
name Blubb
|
||||
baseurl file://%(curdir)s/linkcheck/ftests/data/base/
|
||||
valid
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 198 B |
|
|
@ -1 +0,0 @@
|
|||
file:///etc/group
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/file.asc
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.asc
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.asc
|
||||
valid
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
@font-face {
|
||||
src:url(file.html)
|
||||
}
|
||||
background-image:url(file.html)
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/file.css
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.css
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.css
|
||||
valid
|
||||
|
||||
url file.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
valid
|
||||
|
||||
url file.html (cached)
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
valid
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<a href="file.html">relative url</a>
|
||||
<a href="file.html#isnix">bad anchor</a>
|
||||
<a href="file.html#iswas">good anchor</a>
|
||||
<a href="#isnix">bad anchor</a>
|
||||
<a href="#iswas">good anchor</a>
|
||||
<a href="javascript:loadthis()">javascript url</a>
|
||||
|
||||
<a name="iswas">anchor</a>
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
valid
|
||||
|
||||
url file.html (cached)
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
name relative url
|
||||
valid
|
||||
|
||||
url file.html#isnix
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html#isnix
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
name bad anchor
|
||||
warning Anchor #isnix not found.
|
||||
valid
|
||||
|
||||
url file.html#iswas
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html#iswas
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
name good anchor
|
||||
valid
|
||||
|
||||
url #isnix (cached)
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html#isnix
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
name bad anchor
|
||||
warning Anchor #isnix not found.
|
||||
valid
|
||||
|
||||
url #iswas (cached)
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html#iswas
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
name good anchor
|
||||
valid
|
||||
|
||||
url javascript:loadthis()
|
||||
cache key javascript:loadthis()
|
||||
real url javascript:loadthis()
|
||||
name javascript url
|
||||
warning Javascript URL ignored.
|
||||
valid
|
||||
|
|
@ -1 +0,0 @@
|
|||
file:///etc/group
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/file.txt
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.txt
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.txt
|
||||
valid
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<!-- frame src urls -->
|
||||
<frameset border="0" frameborder="0" framespacing="0">
|
||||
<frame name="top" src="frames.html" frameborder="0">
|
||||
<frame name="bottom" src="frames.html" frameborder="0">
|
||||
</frameset>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/frames.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/frames.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/frames.html
|
||||
valid
|
||||
|
||||
url frames.html (cached)
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/frames.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/frames.html
|
||||
valid
|
||||
|
||||
url frames.html (cached)
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/frames.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/frames.html
|
||||
valid
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
Just some HTTP links
|
||||
<a b=c "boo" href="http://www.garantiertnixgutt.bla/">bad url</a>
|
||||
<a href="http://localhost:8001/">ok</a>
|
||||
<a href="http:/localhost:8001/">one slash</a>
|
||||
<a href="http:localhost:8001/">no slash</a>
|
||||
<a href="http://">no url</a>
|
||||
<a href="http:/">no url, one slash</a>
|
||||
<a href="http:">no url, no slash</a>
|
||||
<a href="http://localhost:8001/stalter&sohn">unquoted ampersand</a>
|
||||
<a href=http://slashdot.org/>unquoted</a>
|
||||
<a href="HtTP://LoCAlHOst:8001/">should be cached</a>
|
||||
<a href="HTTP://LOCALHOST:8001/">should be cached</a>
|
||||
<!-- check cache key with query -->
|
||||
<a href="http://localhost:8001/?d=directory&p=page">should not be cached</a>
|
||||
<a href="http://localhost:8001/?d=directory&p=page1">should not be cached</a>
|
||||
<!-- entities -->
|
||||
<a href="http://localhost:8001/?quoted=ü">html entities</a>
|
||||
<!-- quoting test...
|
||||
<a href=""></a>
|
||||
-->
|
||||
|
||||
<!-- empty form URL -->
|
||||
<form action="" method="GET">
|
||||
</form>
|
||||
|
||||
<!-- multiple links in one tag -->
|
||||
<applet archive="http.html" src="http.html">
|
||||
<!-- css urls -->
|
||||
<img style="@font-face {src:url(http.html)};background-image:url(http.html)"
|
||||
title="CSS urls">
|
||||
|
||||
<!-- <a href=http://nocheckin> no check because of comment -->
|
||||
<a href=http://localhost:8001/">no beginning quote</a>
|
||||
<a href="http://localhost:8001/>no ending quote</a>
|
||||
<!-- check the parser at end of file -->
|
||||
<a href="g
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
url http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
cache key http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
real url http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
valid
|
||||
|
||||
url http://www.garantiertnixgutt.bla/
|
||||
cache key http://www.garantiertnixgutt.bla/
|
||||
real url http://www.garantiertnixgutt.bla/
|
||||
name bad url
|
||||
error
|
||||
|
||||
url http://localhost:8001/
|
||||
cache key http://localhost:8001/
|
||||
real url http://localhost:8001/
|
||||
name ok
|
||||
valid
|
||||
|
||||
url http:/localhost:8001/
|
||||
cache key http:///localhost%%3A8001/
|
||||
real url http:///localhost%%3A8001/
|
||||
name one slash
|
||||
warning Base URL is not properly normed. Normed URL is http:///localhost%%3A8001/.
|
||||
error
|
||||
|
||||
url http:localhost:8001/ (cached)
|
||||
cache key http:///localhost%%3A8001/
|
||||
real url http:///localhost%%3A8001/
|
||||
name no slash
|
||||
warning Base URL is not properly normed. Normed URL is http:///localhost%%3A8001/.
|
||||
error
|
||||
|
||||
url http://
|
||||
cache key http://
|
||||
real url http://
|
||||
name no url
|
||||
error
|
||||
|
||||
url http:/
|
||||
cache key http:///
|
||||
real url http:///
|
||||
name no url, one slash
|
||||
warning Base URL is not properly normed. Normed URL is http:///.
|
||||
error
|
||||
|
||||
url http: (cached)
|
||||
cache key http://
|
||||
real url http://
|
||||
name no url, no slash
|
||||
warning Base URL is not properly normed. Normed URL is http://.
|
||||
error
|
||||
|
||||
url http://localhost:8001/stalter&sohn
|
||||
cache key http://localhost:8001/stalter%%26sohn
|
||||
real url http://localhost:8001/stalter%%26sohn
|
||||
name unquoted ampersand
|
||||
warning Base URL is not properly normed. Normed URL is http://localhost:8001/stalter%%26sohn.
|
||||
error
|
||||
|
||||
url http://slashdot.org/
|
||||
cache key http://slashdot.org/
|
||||
real url http://slashdot.org/
|
||||
name unquoted
|
||||
valid
|
||||
|
||||
url HtTP://LoCAlHOst:8001/ (cached)
|
||||
cache key http://localhost:8001/
|
||||
real url http://localhost:8001/
|
||||
name should be cached
|
||||
warning Base URL is not properly normed. Normed URL is http://localhost:8001/.
|
||||
valid
|
||||
|
||||
url HTTP://LOCALHOST:8001/ (cached)
|
||||
cache key http://localhost:8001/
|
||||
real url http://localhost:8001/
|
||||
name should be cached
|
||||
warning Base URL is not properly normed. Normed URL is http://localhost:8001/.
|
||||
valid
|
||||
|
||||
url http://localhost:8001/?d=directory&p=page
|
||||
cache key http://localhost:8001/?d=directory&p=page
|
||||
real url http://localhost:8001/?d=directory&p=page
|
||||
name should not be cached
|
||||
valid
|
||||
|
||||
url http://localhost:8001/?d=directory&p=page1
|
||||
cache key http://localhost:8001/?d=directory&p=page1
|
||||
real url http://localhost:8001/?d=directory&p=page1
|
||||
name should not be cached
|
||||
valid
|
||||
|
||||
url http://localhost:8001/?quoted=ü
|
||||
cache key http://localhost:8001/?quoted=%%FC
|
||||
real url http://localhost:8001/?quoted=%%FC
|
||||
name html entities
|
||||
warning Base URL is not properly normed. Normed URL is http://localhost:8001/?quoted=%%FC.
|
||||
valid
|
||||
|
||||
url (cached)
|
||||
cache key http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
real url http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
valid
|
||||
|
||||
url http.html (cached)
|
||||
cache key http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
real url http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
valid
|
||||
|
||||
url http.html (cached)
|
||||
cache key http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
real url http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
valid
|
||||
|
||||
url http.html (cached)
|
||||
cache key http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
real url http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
name CSS urls
|
||||
valid
|
||||
|
||||
url http.html (cached)
|
||||
cache key http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
real url http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
name CSS urls
|
||||
valid
|
||||
|
||||
url http://localhost:8001/ (cached)
|
||||
cache key http://localhost:8001/
|
||||
real url http://localhost:8001/
|
||||
name no beginning quote
|
||||
valid
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<!-- meta -->
|
||||
<meta http-equiv="refresh" content="5; url=http://localhost:8001/">
|
||||
<meta rel="SHORTCUT ICON" href="favicon.ico">
|
||||
<meta rel="ICON" href="favicon.ico">
|
||||
|
||||
<!-- empty tag -->
|
||||
<tr background>
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
url
|
||||
cache key None
|
||||
real url None
|
||||
error
|
||||
url file://%(curdir)s/linkcheck/ftests/data/misc.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/misc.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/misc.html
|
||||
valid
|
||||
|
||||
url http://localhost:8001/
|
||||
cache key http://localhost:8001/
|
||||
real url http://localhost:8001/
|
||||
error
|
||||
|
||||
url favicon.ico
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/favicon.ico
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/favicon.ico
|
||||
valid
|
||||
|
||||
url favicon.ico (cached)
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/favicon.ico
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/favicon.ico
|
||||
valid
|
||||
|
|
@ -1 +0,0 @@
|
|||
<a href="newurl.html">Recursive Redirect</a>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
<meta name="robots" content="nofollow">
|
||||
<a href="do_not_check.html">bla</a>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/norobots.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/norobots.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/norobots.html
|
||||
valid
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# LinkChecker url list
|
||||
# empty lines and
|
||||
# comments are ignored
|
||||
|
||||
file.html
|
||||
file.html#isnix
|
||||
file.html#iswas
|
||||
|
||||
javascript:loadthis()
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/urllist.txt
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/urllist.txt
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/urllist.txt
|
||||
valid
|
||||
|
||||
url file.html
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
valid
|
||||
|
||||
url file.html#isnix
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html#isnix
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
warning Anchor #isnix not found.
|
||||
valid
|
||||
|
||||
url file.html#iswas
|
||||
cache key file://%(curdir)s/linkcheck/ftests/data/file.html#iswas
|
||||
real url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
valid
|
||||
|
||||
url javascript:loadthis()
|
||||
cache key javascript:loadthis()
|
||||
real url javascript:loadthis()
|
||||
warning Javascript URL ignored.
|
||||
valid
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Define http test support classes for LinkChecker tests.
|
||||
"""
|
||||
|
||||
import SimpleHTTPServer
|
||||
import BaseHTTPServer
|
||||
import httplib
|
||||
import time
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
|
||||
class StoppableHttpRequestHandler (SimpleHTTPServer.SimpleHTTPRequestHandler, object):
|
||||
"""
|
||||
HTTP request handler with QUIT stopping the server.
|
||||
"""
|
||||
|
||||
def do_QUIT (self):
|
||||
"""
|
||||
Send 200 OK response, and set server.stop to True.
|
||||
"""
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
self.server.stop = True
|
||||
|
||||
def log_message (self, format, *args):
|
||||
"""
|
||||
Logging is disabled.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class StoppableHttpServer (BaseHTTPServer.HTTPServer, object):
|
||||
"""
|
||||
HTTP server that reacts to self.stop flag.
|
||||
"""
|
||||
|
||||
def serve_forever (self):
|
||||
"""
|
||||
Handle one request at a time until stopped.
|
||||
"""
|
||||
self.stop = False
|
||||
while not self.stop:
|
||||
self.handle_request()
|
||||
|
||||
|
||||
class NoQueryHttpRequestHandler (StoppableHttpRequestHandler):
|
||||
"""
|
||||
Handler ignoring the query part of requests.
|
||||
"""
|
||||
|
||||
def remove_path_query (self):
|
||||
"""
|
||||
Remove everything after a question mark.
|
||||
"""
|
||||
i = self.path.find('?')
|
||||
if i != -1:
|
||||
self.path = self.path[:i]
|
||||
|
||||
def do_GET (self):
|
||||
"""
|
||||
Removes query part of GET request.
|
||||
"""
|
||||
self.remove_path_query()
|
||||
super(NoQueryHttpRequestHandler, self).do_GET()
|
||||
|
||||
def do_HEAD (self):
|
||||
"""
|
||||
Removes query part of HEAD request.
|
||||
"""
|
||||
self.remove_path_query()
|
||||
super(NoQueryHttpRequestHandler, self).do_HEAD()
|
||||
|
||||
|
||||
class HttpServerTest (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Start/stop an HTTP server that can be used for testing.
|
||||
"""
|
||||
|
||||
def __init__ (self, methodName='runTest'):
|
||||
"""
|
||||
Init test class and store default http server port.
|
||||
"""
|
||||
super(HttpServerTest, self).__init__(methodName=methodName)
|
||||
self.port = 8001
|
||||
|
||||
def start_server (self, handler=NoQueryHttpRequestHandler):
|
||||
"""
|
||||
Start a new HTTP server in a new thread.
|
||||
"""
|
||||
try:
|
||||
import threading
|
||||
except ImportError:
|
||||
self.fail("This test needs threading support")
|
||||
t = threading.Thread(None, start_server, None, (self.port, handler))
|
||||
t.start()
|
||||
# wait for server to start up
|
||||
time.sleep(3)
|
||||
|
||||
def stop_server (self):
|
||||
"""
|
||||
Send QUIT request to http server.
|
||||
"""
|
||||
conn = httplib.HTTPConnection("localhost:%d" % self.port)
|
||||
conn.request("QUIT", "/")
|
||||
conn.getresponse()
|
||||
|
||||
|
||||
def start_server (port, handler):
|
||||
"""
|
||||
Start an HTTP server on given port.
|
||||
"""
|
||||
ServerClass = StoppableHttpServer
|
||||
server_address = ('', port)
|
||||
handler.protocol_version = "HTTP/1.0"
|
||||
httpd = ServerClass(server_address, handler)
|
||||
httpd.serve_forever()
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test html anchor parsing and checking.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
|
||||
class TestAnchor (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test anchor checking of HTML pages.
|
||||
"""
|
||||
|
||||
def test_anchor (self):
|
||||
"""
|
||||
Test anchors.
|
||||
"""
|
||||
self.file_test("anchor.html")
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestAnchor)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test html <base> tag parsing.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
class TestBase (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test links of base*.html files.
|
||||
"""
|
||||
|
||||
def test_base1 (self):
|
||||
"""
|
||||
Test links of base1.html.
|
||||
"""
|
||||
self.file_test("base1.html")
|
||||
|
||||
def test_base2 (self):
|
||||
"""
|
||||
Test links of base2.html.
|
||||
"""
|
||||
self.file_test("base2.html")
|
||||
|
||||
def test_base3 (self):
|
||||
"""
|
||||
Test links of base3.html.
|
||||
"""
|
||||
self.file_test("base3.html")
|
||||
|
||||
def test_base4 (self):
|
||||
"""
|
||||
Test links of base4.html.
|
||||
"""
|
||||
self.file_test("base4.html")
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestBase)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test error checking.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
import linkcheck.url
|
||||
|
||||
|
||||
class TestError (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test unrecognized or syntactically wrong links.
|
||||
"""
|
||||
|
||||
def test_unrecognized (self):
|
||||
"""
|
||||
Unrecognized scheme test.
|
||||
"""
|
||||
url = u"hutzli:"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key None",
|
||||
u"real url %s" % nurl,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
def test_leading_whitespace (self):
|
||||
"""
|
||||
Leading whitespace test.
|
||||
"""
|
||||
url = u" http://www.heise.de/"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key None",
|
||||
u"real url %s" % nurl,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = u"\nhttp://www.heise.de/"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key None",
|
||||
u"real url %s" % nurl,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
def test_trailing_whitespace (self):
|
||||
"""
|
||||
Trailing whitespace test.
|
||||
"""
|
||||
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"warning Base URL is not properly normed. Normed URL is %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"warning Base URL is not properly normed. Normed URL is %s." % nurl,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
def test_invalid (self):
|
||||
"""
|
||||
Invalid syntax test.
|
||||
"""
|
||||
# invalid scheme chars
|
||||
url = u"äöü?:"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key None",
|
||||
u"real url %s" % nurl,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# missing scheme alltogether
|
||||
url = u"?äöü?"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key None",
|
||||
u"real url %s" % nurl,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# really fucked up
|
||||
url = u"@³²¼][½ ³@] ¬½"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key None",
|
||||
u"real url %s" % nurl,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestError)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""
|
||||
Test container routines.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import os
|
||||
|
||||
import linkcheck.fcgi
|
||||
|
||||
class TestFcgi (unittest.TestCase):
|
||||
"""
|
||||
Test FastCGI request parsing routines.
|
||||
"""
|
||||
|
||||
def _test_non_fcgi_env (self):
|
||||
os.environ = {}
|
||||
req = linkcheck.fcgi.FCGI()
|
||||
fs = req.getFieldStorage()
|
||||
doc = ['<HTML><HEAD><TITLE>FCGI TestApp</TITLE></HEAD>\n'
|
||||
'<BODY>\n']
|
||||
doc.append('<H2>FCGI TestApp</H2><P>')
|
||||
if req.env.has_key('CONTENT_LENGTH'):
|
||||
cl = int(req.env['CONTENT_LENGTH'])
|
||||
doc.append('<br><b>POST data (%s):</b><br><pre>' % cl)
|
||||
keys = fs.keys()
|
||||
keys.sort()
|
||||
for k in keys:
|
||||
val = fs[k]
|
||||
if type(val) == type([]):
|
||||
doc.append(' <b>%-15s :</b> %s\n' %
|
||||
(k, val))
|
||||
else:
|
||||
doc.append(' <b>%-15s :</b> %s\n' %
|
||||
(k, val.value))
|
||||
doc.append('</pre>')
|
||||
doc.append('<P><HR><P><pre>')
|
||||
keys = req.env.keys()
|
||||
keys.sort()
|
||||
for k in keys:
|
||||
doc.append('<b>%-20s :</b> %s\n' % (k, req.env[k]))
|
||||
doc.append('\n</pre><P><HR>\n')
|
||||
doc.append('</BODY></HTML>\n')
|
||||
doc = ''.join(doc)
|
||||
req.out.write('Content-length: %s\r\n'
|
||||
'Content-type: text/html\r\n'
|
||||
'Cache-Control: no-cache\r\n'
|
||||
'\r\n'
|
||||
% len(doc))
|
||||
req.out.write(doc)
|
||||
req.finish()
|
||||
|
||||
def _test_fcgi (self):
|
||||
"""
|
||||
Test FastCGI request parsing routines.
|
||||
"""
|
||||
counter = 0
|
||||
while linkcheck.fcgi.isFCGI():
|
||||
req = linkcheck.fcgi.FCGI()
|
||||
counter += 1
|
||||
fs = req.getFieldStorage()
|
||||
size = int(fs['size'].value)
|
||||
doc = ['*' * size]
|
||||
doc = ''.join(doc)
|
||||
req.out.write('Content-length: %s\r\n'
|
||||
'Content-type: text/html\r\n'
|
||||
'Cache-Control: no-cache\r\n'
|
||||
'\r\n'
|
||||
% len(doc))
|
||||
req.out.write(doc)
|
||||
req.finish()
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestFcgi)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,117 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test file parsing.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import os
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
|
||||
class TestFile (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test file:// link checking (and file content parsing).
|
||||
"""
|
||||
|
||||
def test_html (self):
|
||||
"""
|
||||
Test links of file.html.
|
||||
"""
|
||||
self.file_test("file.html")
|
||||
|
||||
def test_text (self):
|
||||
"""
|
||||
Test links of file.txt.
|
||||
"""
|
||||
self.file_test("file.txt")
|
||||
|
||||
def test_asc (self):
|
||||
"""
|
||||
Test links of file.asc.
|
||||
"""
|
||||
self.file_test("file.asc")
|
||||
|
||||
def test_css (self):
|
||||
"""
|
||||
Test links of file.css.
|
||||
"""
|
||||
self.file_test("file.css")
|
||||
|
||||
def test_urllist (self):
|
||||
"""
|
||||
Test url list parsing.
|
||||
"""
|
||||
self.file_test("urllist.txt")
|
||||
|
||||
def test_files (self):
|
||||
"""
|
||||
Test some direct file links.
|
||||
"""
|
||||
attrs = {'curdir': os.getcwd(),
|
||||
'datadir': 'linkcheck/ftests/data',
|
||||
}
|
||||
# good file
|
||||
url = u"file://%(curdir)s/%(datadir)s/file.txt" % attrs
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# bad file
|
||||
url = u"file:/%(curdir)s/%(datadir)s/file.txt" % attrs
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# good file (missing double slash)
|
||||
url = u"file:%(curdir)s/%(datadir)s/file.txt" % attrs
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key file://%(curdir)s/%(datadir)s/file.txt" % attrs,
|
||||
u"real url file://%(curdir)s/%(datadir)s/file.txt" % attrs,
|
||||
u"warning Base URL is not properly normed. Normed URL is %s." % nurl,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# good dir
|
||||
url = u"file://%(curdir)s/%(datadir)s/" % attrs
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestFile)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test html <frame> tag parsing.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
class TestFrames (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test link checking of HTML framesets.
|
||||
"""
|
||||
|
||||
def test_frames (self):
|
||||
"""
|
||||
Test links of frames.html.
|
||||
"""
|
||||
self.file_test("frames.html")
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestFrames)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test ftp checking.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
|
||||
class TestFtp (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test ftp: link checking.
|
||||
"""
|
||||
|
||||
needed_resources = ['network']
|
||||
|
||||
def test_ftp (self):
|
||||
"""
|
||||
Test ftp link.
|
||||
"""
|
||||
# ftp two slashes
|
||||
url = u"ftp://ftp.debian.org/"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
def test_ftp_slashes (self):
|
||||
"""
|
||||
Test ftp links with missing slashes.
|
||||
"""
|
||||
# ftp one slash
|
||||
url = u"ftp:/ftp.debian.org/"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % nurl,
|
||||
u"warning Base URL is not properly normed. Normed URL is %s." % nurl,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# missing path
|
||||
url = u"ftp://ftp.debian.org"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % nurl,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# missing trailing dir slash
|
||||
url = u"ftp://ftp.debian.org/debian"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s/" % nurl,
|
||||
u"warning Missing trailing directory slash in ftp url.",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
def test_ftp_many_slashes (self):
|
||||
"""
|
||||
Test ftp links with too many slashes.
|
||||
"""
|
||||
# ftp two dir slashes
|
||||
url = u"ftp://ftp.debian.org//debian/"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % nurl,
|
||||
u"warning Base URL is not properly normed. Normed URL is %s." % nurl,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# ftp many dir slashes
|
||||
url = u"ftp://ftp.debian.org////////debian/"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % nurl,
|
||||
u"warning Base URL is not properly normed. Normed URL is %s." % nurl,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# ftp three slashes
|
||||
url = u"ftp:///ftp.debian.org/"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestFtp)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test http checking.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import re
|
||||
|
||||
import linkcheck.ftests.httptest
|
||||
|
||||
|
||||
class TestHttp (linkcheck.ftests.httptest.HttpServerTest):
|
||||
"""
|
||||
Test http:// link checking.
|
||||
"""
|
||||
|
||||
def test_html (self):
|
||||
try:
|
||||
self.start_server(handler=RedirectHttpRequestHandler)
|
||||
url = u"http://localhost:%d/linkcheck/ftests/data/http.html" % \
|
||||
self.port
|
||||
resultlines = self.get_resultlines("http.html")
|
||||
self.direct(url, resultlines, recursionlevel=1, cmdline=True)
|
||||
self.redirect_http_test()
|
||||
self.noproxyfor_test()
|
||||
finally:
|
||||
self.stop_server()
|
||||
|
||||
def test_redirect (self):
|
||||
try:
|
||||
self.start_server(handler=RedirectHttpsRequestHandler)
|
||||
self.redirect_https_test()
|
||||
finally:
|
||||
self.stop_server()
|
||||
|
||||
def redirect_https_test (self):
|
||||
url = u"http://localhost:%d/redirect1" % self.port
|
||||
nurl = url
|
||||
rurl = url.replace('redirect', 'newurl')
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % nurl,
|
||||
u"info Redirected to %s." % rurl.replace('http:', 'https:'),
|
||||
u"info The redirected URL is outside of the domain filter, " \
|
||||
u"checked only syntax.",
|
||||
u"warning Redirection to different URL type encountered; the " \
|
||||
u"original URL was u'http://localhost:%d/redirect1'." % self.port,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines, recursionlevel=0, cmdline=True)
|
||||
|
||||
def redirect_http_test (self):
|
||||
url = u"http://localhost:%d/redirect1" % self.port
|
||||
nurl = url
|
||||
rurl = url.replace("redirect", "newurl")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % rurl,
|
||||
u"info Redirected to %s." % rurl,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines, recursionlevel=0, cmdline=True)
|
||||
url = u"http://localhost:%d/linkcheck/ftests/data/redirect.html" % \
|
||||
self.port
|
||||
nurl = url
|
||||
rurl = url.replace("redirect", "newurl")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % rurl,
|
||||
u"info Redirected to %s." % rurl,
|
||||
u"valid",
|
||||
u"url newurl.html",
|
||||
u"cache key %s" % rurl,
|
||||
u"real url %s" % rurl,
|
||||
u"name Recursive Redirect",
|
||||
u"valid",
|
||||
u"url newurl.html (cached)",
|
||||
u"cache key %s" % nurl.replace("redirect", "newurl"),
|
||||
u"real url %s" % rurl.replace("redirect", "newurl"),
|
||||
u"name Recursive Redirect",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines, recursionlevel=99, cmdline=True)
|
||||
|
||||
def noproxyfor_test (self):
|
||||
"""
|
||||
Test setting proxy and --no-proxy-for option.
|
||||
"""
|
||||
os.environ["http_proxy"] = "http://imadoofus:8877"
|
||||
confargs = {"noproxyfor": [re.compile("localhost")]}
|
||||
url = u"http://localhost:%d/linkcheck/ftests/data/http.html" % \
|
||||
self.port
|
||||
nurl = url
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % nurl,
|
||||
u"info Ignoring proxy setting 'imadoofus:8877'",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines, recursionlevel=0,
|
||||
confargs=confargs, cmdline=True)
|
||||
del os.environ["http_proxy"]
|
||||
|
||||
|
||||
class RedirectHttpRequestHandler (linkcheck.ftests.httptest.NoQueryHttpRequestHandler):
|
||||
"""
|
||||
Handler redirecting certain requests.
|
||||
"""
|
||||
|
||||
def redirect (self):
|
||||
"""
|
||||
Redirect request.
|
||||
"""
|
||||
path = self.path.replace("redirect", "newurl")
|
||||
self.send_response(302)
|
||||
self.send_header("Location", path)
|
||||
self.end_headers()
|
||||
|
||||
def do_GET (self):
|
||||
"""
|
||||
Removes query part of GET request.
|
||||
"""
|
||||
if "redirect" in self.path:
|
||||
self.redirect()
|
||||
else:
|
||||
super(RedirectHttpRequestHandler, self).do_GET()
|
||||
|
||||
def do_HEAD (self):
|
||||
if "redirect" in self.path:
|
||||
self.redirect()
|
||||
else:
|
||||
super(RedirectHttpRequestHandler, self).do_HEAD()
|
||||
|
||||
class RedirectHttpsRequestHandler (RedirectHttpRequestHandler):
|
||||
|
||||
def redirect (self):
|
||||
"""
|
||||
Redirect request.
|
||||
"""
|
||||
path = self.path.replace("redirect", "newurl")
|
||||
port = self.server.server_address[1]
|
||||
url = "https://localhost:%d%s" % (port, path)
|
||||
self.send_response(302)
|
||||
self.send_header("Location", url)
|
||||
self.end_headers()
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestHttp)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test news checking.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
class TestHttps (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test https: link checking.
|
||||
"""
|
||||
|
||||
needed_resources = ['network']
|
||||
|
||||
def test_https (self):
|
||||
"""
|
||||
Test some https links.
|
||||
"""
|
||||
url = u"https://sourceforge.net/"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestHttps)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test mail checking.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
class TestMail (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test mailto: link checking.
|
||||
"""
|
||||
|
||||
needed_resources = ['network']
|
||||
|
||||
def test_good_mail (self):
|
||||
"""
|
||||
Test some good mailto addrs.
|
||||
"""
|
||||
url = self.norm(u"mailto:Dude <calvin@users.sf.net> , "\
|
||||
"Killer <calvin@users.sourceforge.net>?subject=bla")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key mailto:calvin@users.sf.net,"
|
||||
u"calvin@users.sourceforge.net",
|
||||
u"real url %s" % url,
|
||||
u"info Verified address: <calvin@users.sf.net> is deliverable.",
|
||||
u"info Verified address: <calvin@users.sourceforge.net> is "\
|
||||
"deliverable.",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.norm(u"mailto:Bastian Kleineidam <calvin@users.sf.net>?"\
|
||||
"bcc=calvin%40users.sourceforge.net")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key mailto:calvin@users.sf.net,"
|
||||
u"calvin@users.sourceforge.net",
|
||||
u"real url %s" % url,
|
||||
u"info Verified address: <calvin@users.sf.net> is deliverable.",
|
||||
u"info Verified address: <calvin@users.sourceforge.net> is "\
|
||||
"deliverable.",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.norm(u"mailto:Bastian Kleineidam <calvin@users.sf.net>")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key mailto:calvin@users.sf.net",
|
||||
u"real url %s" % url,
|
||||
u"info Verified address: <calvin@users.sf.net> is deliverable.",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.norm(u"mailto:o'hara@users.sf.net")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key mailto:o'hara@users.sf.net",
|
||||
u"real url %s" % url,
|
||||
u"warning Unverified address: <o'hara@users.sf.net> Unrouteable address.",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.norm(u"mailto:?to=calvin@users.sf.net&subject=blubb&"
|
||||
u"cc=calvin_cc@users.sf.net&CC=calvin_CC@users.sf.net")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key mailto:calvin@users.sf.net,"
|
||||
u"calvin_CC@users.sf.net,calvin_cc@users.sf.net",
|
||||
u"real url %s" % url,
|
||||
u"info Verified address: <calvin@users.sf.net> is deliverable.",
|
||||
u"warning Unverified address: <calvin_cc@users.sf.net> Unrouteable address.",
|
||||
u"warning Unverified address: <calvin_CC@users.sf.net> Unrouteable address.",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.norm(u"mailto:news-admins@freshmeat.net?subject="
|
||||
"Re:%20[fm%20#11093]%20(news-admins)%20Submission%20"
|
||||
"report%20-%20Pretty%20CoLoRs")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key mailto:news-admins@freshmeat.net",
|
||||
u"real url %s" % url,
|
||||
u"warning Unverified address: VRFY command is disabled.",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.norm(u"mailto:foo@foo-bar.de?subject=test")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key mailto:foo@foo-bar.de",
|
||||
u"real url %s" % url,
|
||||
u"info Unverified address: Cannot VRFY user; "
|
||||
u"try RCPT to attempt delivery. But mail will be sent anyway.",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
def test_warn_mail (self):
|
||||
"""
|
||||
Test some mailto addrs with warnings.
|
||||
"""
|
||||
# contains non-quoted characters
|
||||
url = u"mailto:calvin@users.sf.net?subject=äöü"
|
||||
qurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key mailto:calvin@users.sf.net",
|
||||
u"real url %s" % qurl,
|
||||
u"info Verified address: <calvin@users.sf.net> is deliverable.",
|
||||
u"warning Base URL is not properly normed. "
|
||||
u"Normed URL is %s." % qurl,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = u"mailto:calvin@users.sf.net?subject=Halli hallo"
|
||||
qurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key mailto:calvin@users.sf.net",
|
||||
u"real url %s" % qurl,
|
||||
u"info Verified address: <calvin@users.sf.net> is deliverable.",
|
||||
u"warning Base URL is not properly normed. "
|
||||
u"Normed URL is %s." % qurl,
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.norm(u"mailto:")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"warning No addresses found.",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
def test_bad_mail (self):
|
||||
"""
|
||||
Test some mailto addrs with bad syntax.
|
||||
"""
|
||||
# ? extension forbidden in <> construct
|
||||
url = self.norm(u"mailto:Bastian Kleineidam "\
|
||||
"<calvin@users.sf.net?foo=bar>")
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key None",
|
||||
u"real url %s" % url,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestMail)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test miscellaneous html tag parsing.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
class TestMisc (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test link checking of HTML tags.
|
||||
"""
|
||||
|
||||
def test_misc (self):
|
||||
"""
|
||||
Test links of misc.html.
|
||||
"""
|
||||
self.file_test("misc.html")
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestMisc)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test news checking.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
import linkcheck.url
|
||||
|
||||
|
||||
class TestNews (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test nntp: and news: link checking.
|
||||
"""
|
||||
|
||||
needed_resources = ['network']
|
||||
|
||||
def newstest (self, url, resultlines):
|
||||
fields = ['url', 'cachekey', 'realurl', 'warning', 'result', ]
|
||||
self.direct(url, resultlines, fields=fields)
|
||||
|
||||
def test_news (self):
|
||||
"""
|
||||
Test news: link.
|
||||
"""
|
||||
# news testing
|
||||
url = u"news:comp.os.linux.misc"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"warning No NNTP server was specified, skipping this URL.",
|
||||
u"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
# no group
|
||||
url = u"news:"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"warning No NNTP server was specified, skipping this URL.",
|
||||
u"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
|
||||
def test_snews (self):
|
||||
"""
|
||||
Test snews: link.
|
||||
"""
|
||||
url = u"snews:de.comp.os.unix.linux.misc"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % nurl,
|
||||
u"warning Base URL is not properly normed. Normed URL is %s." % nurl,
|
||||
u"warning No NNTP server was specified, skipping this URL.",
|
||||
u"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
|
||||
def test_illegal (self):
|
||||
# illegal syntax
|
||||
url = u"news:§$%&/´`(§%"
|
||||
qurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % qurl,
|
||||
u"real url %s" % qurl,
|
||||
u"warning Base URL is not properly normed. Normed URL is %s." % qurl,
|
||||
u"warning No NNTP server was specified, skipping this URL.",
|
||||
u"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
|
||||
def test_nntp (self):
|
||||
"""
|
||||
Nttp scheme with host.
|
||||
"""
|
||||
url = u"nntp://news.yaako.com/comp.lang.python"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"info News group comp.lang.python found.",
|
||||
u"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
|
||||
def test_article_span (self):
|
||||
"""
|
||||
Article span.
|
||||
"""
|
||||
url = u"nntp://news.yaako.com/comp.lang.python/1-5"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"info News group comp.lang.python found.",
|
||||
u"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
url = u"news:comp.lang.python/1-5"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"warning No NNTP server was specified, skipping this URL.",
|
||||
u"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
|
||||
def test_host_no_group (self):
|
||||
"""
|
||||
Host but no group.
|
||||
"""
|
||||
url = u"nntp://news.yaako.com/"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"warning No newsgroup specified in NNTP URL.",
|
||||
u"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestNews)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test HTML robots.txt parsing.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
|
||||
class TestRobotsTxt (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test robots.txt directive parsing in HTML files.
|
||||
"""
|
||||
|
||||
def test_norobot (self):
|
||||
"""
|
||||
Test links of norobot.html.
|
||||
"""
|
||||
self.file_test("norobots.html")
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestRobotsTxt)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004-2005 Bastian Kleineidam
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
Test telnet checking.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
|
||||
class TestTelnet (linkcheck.ftests.StandardTest):
|
||||
"""
|
||||
Test telnet: link checking.
|
||||
"""
|
||||
|
||||
def test_telnet (self):
|
||||
url = u"telnet:"
|
||||
nurl = self.norm(url)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % nurl,
|
||||
u"warning Base URL is not properly normed. Normed URL is %s." % nurl,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = u"telnet://www.imarealdoofus.com"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = u"telnet://user@www.imarealdoofus.com"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = u"telnet://user:pass@www.imarealdoofus.com"
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % url,
|
||||
u"real url %s" % url,
|
||||
u"error",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
return unittest.makeSuite(TestTelnet)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Reference in a new issue