mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-09 15:14:45 +00:00
functional tests
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1422 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
14a9b5c426
commit
1cf5a14352
34 changed files with 1095 additions and 0 deletions
126
linkcheck/ftests/__init__.py
Normal file
126
linkcheck/ftests/__init__.py
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""define standard test support classes funtional for LinkChecker tests"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import difflib
|
||||
|
||||
import linkcheck.checker
|
||||
import linkcheck.configuration
|
||||
import linkcheck.logger
|
||||
|
||||
|
||||
class TestLogger (linkcheck.logger.Logger):
|
||||
"""Output logger for automatic regression tests"""
|
||||
|
||||
def __init__ (self, **kwargs):
|
||||
"""kwargs must have "expected" keyword with the expected logger
|
||||
output lines"""
|
||||
super(TestLogger, self).__init__(**kwargs)
|
||||
self.expected = kwargs['expected']
|
||||
self.result = []
|
||||
self.diff = []
|
||||
|
||||
def start_output (self):
|
||||
"""nothing to do here"""
|
||||
pass
|
||||
|
||||
def new_url (self, url_data):
|
||||
"""append logger output to self.result"""
|
||||
if self.has_field('url'):
|
||||
url = "url %s" % url_data.base_url
|
||||
if url_data.cached:
|
||||
url += " (cached)"
|
||||
self.result.append(url)
|
||||
if self.has_field('name') and url_data.name:
|
||||
self.result.append("name %s" % url_data.name)
|
||||
if self.has_field('base') and url_data.base_ref:
|
||||
self.result.append("baseurl %s" % url_data.base_ref)
|
||||
if self.has_field('info'):
|
||||
for info in url_data.info:
|
||||
self.result.append("info %s" % info)
|
||||
if self.has_field('warning'):
|
||||
for warning in url_data.warning:
|
||||
self.result.append("warning %s" % warning)
|
||||
if self.has_field('result'):
|
||||
self.result.append(url_data.valid and "valid" or "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):
|
||||
self.diff.append(line)
|
||||
|
||||
|
||||
def get_test_config (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.set_threads(0)
|
||||
for key, value in confargs.items():
|
||||
config[key] = value
|
||||
return config
|
||||
|
||||
|
||||
class StandardTest (unittest.TestCase, object):
|
||||
"""functional test class with ability to test local files"""
|
||||
|
||||
def quote (self, url):
|
||||
"""helper function quote a url"""
|
||||
return linkcheck.url.url_norm(url)
|
||||
|
||||
def get_file (self, filename):
|
||||
"""get absolute file name, located within 'data' directory"""
|
||||
return os.path.join("linkcheck", "ftests", "data", filename)
|
||||
|
||||
def get_resultlines (self, filename):
|
||||
"""return contents of file, as list of lines"""
|
||||
resultfile = self.get_file(filename+".result")
|
||||
f = open(resultfile)
|
||||
resultlines = [line.rstrip('\r\n') % {'curdir': os.getcwd()} \
|
||||
for line in f]
|
||||
f.close()
|
||||
return resultlines
|
||||
|
||||
def file_test (self, filename):
|
||||
"""check <filename> with expected result in <filename>.result"""
|
||||
url = self.get_file(filename)
|
||||
confargs = {}
|
||||
logargs = {'expected': self.get_resultlines(filename)}
|
||||
config = get_test_config(confargs, logargs)
|
||||
config.append_url(linkcheck.checker.get_url_from(url, 0, config))
|
||||
linkcheck.checker.check_urls(config)
|
||||
if config['logger'].diff:
|
||||
self.fail(os.linesep.join([url] + config['logger'].diff))
|
||||
|
||||
def direct (self, url, resultlines, fields=None, recursionlevel=0):
|
||||
"""check url with expected result"""
|
||||
confargs = {'recursionlevel': recursionlevel}
|
||||
logargs = {'expected': resultlines}
|
||||
if fields is not None:
|
||||
logargs['fields'] = fields
|
||||
config = get_test_config(confargs, logargs)
|
||||
config.append_url(linkcheck.checker.get_url_from(url, 0, config))
|
||||
linkcheck.checker.check_urls(config)
|
||||
if config['logger'].diff:
|
||||
self.fail(os.linesep.join([url]+config['logger'].diff))
|
||||
4
linkcheck/ftests/data/anchor.html
Normal file
4
linkcheck/ftests/data/anchor.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<a href="#myid">Bla</a>
|
||||
<ul>
|
||||
<li id="myid">
|
||||
</ul>
|
||||
5
linkcheck/ftests/data/anchor.html.result
Normal file
5
linkcheck/ftests/data/anchor.html.result
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/anchor.html
|
||||
valid
|
||||
url #myid
|
||||
name Bla
|
||||
valid
|
||||
0
linkcheck/ftests/data/base/test.txt
Normal file
0
linkcheck/ftests/data/base/test.txt
Normal file
8
linkcheck/ftests/data/base1.html
Normal file
8
linkcheck/ftests/data/base1.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<!-- 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">
|
||||
6
linkcheck/ftests/data/base1.html.result
Normal file
6
linkcheck/ftests/data/base1.html.result
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/base1.html
|
||||
valid
|
||||
url base2.html
|
||||
valid
|
||||
url base2.html (cached)
|
||||
valid
|
||||
3
linkcheck/ftests/data/base2.html
Normal file
3
linkcheck/ftests/data/base2.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<!-- base with href -->
|
||||
<base href="base/">
|
||||
<a href="test.txt">
|
||||
5
linkcheck/ftests/data/base2.html.result
Normal file
5
linkcheck/ftests/data/base2.html.result
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/base2.html
|
||||
valid
|
||||
url test.txt
|
||||
baseurl file://%(curdir)s/linkcheck/ftests/data/base/
|
||||
valid
|
||||
2
linkcheck/ftests/data/base3.html
Normal file
2
linkcheck/ftests/data/base3.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!-- codebase test -->
|
||||
<applet codebase="base/" archive="test.txt">
|
||||
5
linkcheck/ftests/data/base3.html.result
Normal file
5
linkcheck/ftests/data/base3.html.result
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/base3.html
|
||||
valid
|
||||
url test.txt
|
||||
baseurl file://%(curdir)s/linkcheck/ftests/data/base/
|
||||
valid
|
||||
1
linkcheck/ftests/data/file.asc
Normal file
1
linkcheck/ftests/data/file.asc
Normal file
|
|
@ -0,0 +1 @@
|
|||
file:///etc/group
|
||||
2
linkcheck/ftests/data/file.asc.result
Normal file
2
linkcheck/ftests/data/file.asc.result
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/file.asc
|
||||
valid
|
||||
4
linkcheck/ftests/data/file.css
Normal file
4
linkcheck/ftests/data/file.css
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
@font-face {
|
||||
src:url(file.html)
|
||||
}
|
||||
background-image:url(file.html)
|
||||
6
linkcheck/ftests/data/file.css.result
Normal file
6
linkcheck/ftests/data/file.css.result
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/file.css
|
||||
valid
|
||||
url file.html
|
||||
valid
|
||||
url file.html (cached)
|
||||
valid
|
||||
9
linkcheck/ftests/data/file.html
Normal file
9
linkcheck/ftests/data/file.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<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="hutzli:nixgutt">bad scheme</a>
|
||||
<a href="javascript:loadthis()">javascript url</a>
|
||||
|
||||
<a name="iswas">anchor</a>
|
||||
26
linkcheck/ftests/data/file.html.result
Normal file
26
linkcheck/ftests/data/file.html.result
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/file.html
|
||||
valid
|
||||
url file.html (cached)
|
||||
name relative url
|
||||
valid
|
||||
url file.html#isnix
|
||||
name bad anchor
|
||||
warning anchor #isnix not found
|
||||
valid
|
||||
url file.html#iswas
|
||||
name good anchor
|
||||
valid
|
||||
url #isnix (cached)
|
||||
name bad anchor
|
||||
warning anchor #isnix not found
|
||||
valid
|
||||
url #iswas (cached)
|
||||
name good anchor
|
||||
valid
|
||||
url hutzli:nixgutt
|
||||
name bad scheme
|
||||
error
|
||||
url javascript:loadthis()
|
||||
name javascript url
|
||||
warning Javascript url ignored
|
||||
valid
|
||||
1
linkcheck/ftests/data/file.txt
Normal file
1
linkcheck/ftests/data/file.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
file:///etc/group
|
||||
2
linkcheck/ftests/data/file.txt.result
Normal file
2
linkcheck/ftests/data/file.txt.result
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/file.txt
|
||||
valid
|
||||
5
linkcheck/ftests/data/frames.html
Normal file
5
linkcheck/ftests/data/frames.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<!-- 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>
|
||||
6
linkcheck/ftests/data/frames.html.result
Normal file
6
linkcheck/ftests/data/frames.html.result
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
url file://%(curdir)s/linkcheck/ftests/data/frames.html
|
||||
valid
|
||||
url frames.html (cached)
|
||||
valid
|
||||
url frames.html (cached)
|
||||
valid
|
||||
31
linkcheck/ftests/data/http.html
Normal file
31
linkcheck/ftests/data/http.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
Just some HTTP links
|
||||
<a b=c "boo" href="http://www.garantiertnixgutt.bla/">bad url</a>
|
||||
<a href="http://localhost:8000/">ok</a>
|
||||
<a href="http:/localhost:8000/">one slash</a>
|
||||
<a href="http:localhost:8000/">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:8000/stalter&sohn">unquoted ampersand</a>
|
||||
<a href=http://slashdot.org/>unquoted</a>
|
||||
<a href="HtTP://LoCAlHOst:8000/">should be cached</a>
|
||||
<a href="HTTP://LOCALHOST:8000/">should be cached</a>
|
||||
<!-- entities -->
|
||||
<a href="http://localhost:8000/?quoted=ü">html entities</a>
|
||||
<!-- quoting test...
|
||||
<a href=""></a>
|
||||
-->
|
||||
|
||||
<!-- meta url -->
|
||||
<meta http-equiv="refresh" content="5; url=http://localhost:8000/">
|
||||
<!-- 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:8000/">no beginning quote</a>
|
||||
<a href="http://localhost:8000/>no ending quote</a>
|
||||
<!-- check the parser at end of file -->
|
||||
<a href="g
|
||||
57
linkcheck/ftests/data/http.html.result
Normal file
57
linkcheck/ftests/data/http.html.result
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
url http://localhost:8001/linkcheck/ftests/data/http.html
|
||||
valid
|
||||
url http://www.garantiertnixgutt.bla/
|
||||
name bad url
|
||||
error
|
||||
url http://localhost:8000/
|
||||
name ok
|
||||
error
|
||||
url http:/localhost:8000/
|
||||
name one slash
|
||||
error
|
||||
url http:localhost:8000/
|
||||
name no slash
|
||||
error
|
||||
url http://
|
||||
name no url
|
||||
warning URL path is empty, assuming '/' as path
|
||||
error
|
||||
url http:/ (cached)
|
||||
name no url, one slash
|
||||
warning URL path is empty, assuming '/' as path
|
||||
error
|
||||
url http: (cached)
|
||||
name no url, no slash
|
||||
warning URL path is empty, assuming '/' as path
|
||||
error
|
||||
url http://localhost:8000/stalter&sohn
|
||||
name unquoted ampersand
|
||||
error
|
||||
url http://slashdot.org/
|
||||
name unquoted
|
||||
valid
|
||||
url HtTP://LoCAlHOst:8000/ (cached)
|
||||
name should be cached
|
||||
error
|
||||
url HTTP://LOCALHOST:8000/ (cached)
|
||||
name should be cached
|
||||
error
|
||||
url http://localhost:8000/?quoted=%%FC
|
||||
name html entities
|
||||
warning Base URL is not properly quoted
|
||||
error
|
||||
url http://localhost:8000/ (cached)
|
||||
error
|
||||
url http.html (cached)
|
||||
valid
|
||||
url http.html (cached)
|
||||
valid
|
||||
url http.html (cached)
|
||||
name CSS urls
|
||||
valid
|
||||
url http.html (cached)
|
||||
name CSS urls
|
||||
valid
|
||||
url http://localhost:8000/ (cached)
|
||||
name no beginning quote
|
||||
error
|
||||
84
linkcheck/ftests/httptest.py
Normal file
84
linkcheck/ftests/httptest.py
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""define http test support classes for LinkChecker tests"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
import SimpleHTTPServer
|
||||
import BaseHTTPServer
|
||||
import httplib
|
||||
import time
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
|
||||
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):
|
||||
"""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,))
|
||||
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()
|
||||
|
||||
|
||||
class StoppableHttpRequestHandler (SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
"""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):
|
||||
"""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()
|
||||
|
||||
|
||||
def start_server (port):
|
||||
"""start an HTTP server on given port"""
|
||||
HandlerClass = StoppableHttpRequestHandler
|
||||
ServerClass = StoppableHttpServer
|
||||
server_address = ('', port)
|
||||
HandlerClass.protocol_version = "HTTP/1.0"
|
||||
httpd = ServerClass(server_address, HandlerClass)
|
||||
httpd.serve_forever()
|
||||
39
linkcheck/ftests/test_anchor.py
Normal file
39
linkcheck/ftests/test_anchor.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test html anchor parsing and checking"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
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"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestAnchor))
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
46
linkcheck/ftests/test_base.py
Normal file
46
linkcheck/ftests/test_base.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test html <base> tag parsing"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
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_suite ():
|
||||
"""build and return a TestSuite"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestBase))
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
72
linkcheck/ftests/test_fcgi.py
Normal file
72
linkcheck/ftests/test_fcgi.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test container routines"""
|
||||
|
||||
import unittest
|
||||
import os
|
||||
|
||||
class TestFcgi (unittest.TestCase):
|
||||
"""test FastCGI request parsing routines"""
|
||||
|
||||
def _test_fcgi (self):
|
||||
"""test FastCGI request parsing routines"""
|
||||
# XXX inactive
|
||||
counter = 0
|
||||
try:
|
||||
while isFCGI():
|
||||
req = FCGI()
|
||||
counter += 1
|
||||
try:
|
||||
fs = req.getFieldStorage()
|
||||
size = int(fs['size'].value)
|
||||
doc = ['*' * size]
|
||||
except:
|
||||
doc = ['<HTML><HEAD><TITLE>FCGI TestApp</TITLE></HEAD>\n'
|
||||
'<BODY>\n']
|
||||
doc.append('<H2>FCGI TestApp</H2><P>')
|
||||
doc.append('<b>request count</b> = %d<br>' % counter)
|
||||
doc.append('<b>pid</b> = %s<br>' % os.getpid())
|
||||
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()
|
||||
except:
|
||||
import traceback
|
||||
f = file('traceback', 'w')
|
||||
traceback.print_exc(file = f)
|
||||
#f.write('%s' % doc)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""build and return a TestSuite"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestFcgi))
|
||||
return suite
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
75
linkcheck/ftests/test_file.py
Normal file
75
linkcheck/ftests/test_file.py
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test file parsing"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
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_files (self):
|
||||
"""test some direct file links"""
|
||||
attrs = {'curdir': os.getcwd(),
|
||||
'datadir': 'linkcheck/ftests/data',
|
||||
}
|
||||
# good file
|
||||
url = "file://%(curdir)s/%(datadir)s/file.txt"%attrs
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
# bad file
|
||||
url = "file:/%(curdir)s/%(datadir)s/file.txt"%attrs
|
||||
resultlines = ["url %s" % url, "error"]
|
||||
self.direct(url, resultlines)
|
||||
# good file
|
||||
url = "file:%(curdir)s/%(datadir)s/file.txt"%attrs
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
# good dir
|
||||
url = "file://%(curdir)s/%(datadir)s/"%attrs
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""build and return a TestSuite"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestFile))
|
||||
return suite
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
38
linkcheck/ftests/test_frames.py
Normal file
38
linkcheck/ftests/test_frames.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test html <frame> tag parsing"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
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"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestFrames))
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
67
linkcheck/ftests/test_ftp.py
Normal file
67
linkcheck/ftests/test_ftp.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test ftp checking"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
|
||||
class TestFtp (linkcheck.ftests.StandardTest):
|
||||
"""test ftp: link checking"""
|
||||
|
||||
def test_ftp (self):
|
||||
"""test some ftp links"""
|
||||
# ftp one slash
|
||||
url = "ftp:/ftp.debian.org/"
|
||||
resultlines = ["url %s" % url, "error"]
|
||||
self.direct(url, resultlines)
|
||||
# ftp two slashes
|
||||
url = "ftp://ftp.debian.org/"
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
# ftp two dir slashes
|
||||
url = "ftp://ftp.debian.org//debian/"
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
# missing trailing dir slash
|
||||
url = "ftp://ftp.debian.org/debian"
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"warning Missing trailing directory slash in ftp url",
|
||||
"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# ftp many dir slashes
|
||||
url = "ftp://ftp.debian.org////////debian/"
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
# ftp three slashes
|
||||
url = "ftp:///ftp.debian.org/"
|
||||
resultlines = ["url %s" % url, "error"]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""build and return a TestSuite"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestFtp))
|
||||
return suite
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
46
linkcheck/ftests/test_http.py
Normal file
46
linkcheck/ftests/test_http.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test http checking"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
import unittest
|
||||
import os
|
||||
|
||||
import linkcheck.ftests.httptest
|
||||
|
||||
|
||||
class TestHttp (linkcheck.ftests.httptest.HttpServerTest):
|
||||
"""test http:// link checking"""
|
||||
|
||||
def test_html (self):
|
||||
self.start_server()
|
||||
url = "http://localhost:%d/linkcheck/ftests/data/http.html"%self.port
|
||||
resultlines = self.get_resultlines("http.html")
|
||||
try:
|
||||
self.direct(url, resultlines, recursionlevel=1)
|
||||
finally:
|
||||
self.stop_server()
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""build and return a TestSuite"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestHttp))
|
||||
return suite
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
41
linkcheck/ftests/test_https.py
Normal file
41
linkcheck/ftests/test_https.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test news checking"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
class TestHttps (linkcheck.ftests.StandardTest):
|
||||
"""test https: link checking"""
|
||||
|
||||
def test_mail (self):
|
||||
"""test some https links"""
|
||||
url = "https://sourceforge.net/"
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""build and return a TestSuite"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestHttps))
|
||||
return suite
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
123
linkcheck/ftests/test_mail.py
Normal file
123
linkcheck/ftests/test_mail.py
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test mail checking"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
import unittest
|
||||
import urllib
|
||||
import os
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
class TestMail (linkcheck.ftests.StandardTest):
|
||||
"""test mailto: link checking"""
|
||||
|
||||
def test_good_mail (self):
|
||||
"""test some good mailto addrs"""
|
||||
url = self.quote("mailto:Dude <calvin@users.sf.net> , "\
|
||||
"Killer <calvin@users.sourceforge.net>?subject=bla")
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"info Verified adress: <calvin> is deliverable",
|
||||
"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.quote("mailto:Bastian Kleineidam <calvin@users.sf.net>?"\
|
||||
"bcc=calvin%40users.sf.net")
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"info Verified adress: <calvin> is deliverable",
|
||||
"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.quote("mailto:Bastian Kleineidam <calvin@users.sf.net>")
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"info Verified adress: <calvin> is deliverable",
|
||||
"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.quote("mailto:o'hara@users.sf.net")
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"info Verified adress: <o'hara> is deliverable",
|
||||
"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.quote("mailto:?to=calvin@users.sf.net&subject=blubb&"\
|
||||
"cc=calvin_cc@users.sf.net&CC=calvin_CC@users.sf.net")
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"info Verified adress: <calvin> is deliverable",
|
||||
"info Verified adress: <calvin_cc> is deliverable",
|
||||
"info Verified adress: <calvin_CC> is deliverable",
|
||||
"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
url = self.quote("mailto:news-admins@freshmeat.net?subject="\
|
||||
"Re:%20[fm%20#11093]%20(news-admins)%20Submission%20"\
|
||||
"report%20-%20Pretty%20CoLoRs")
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
url = self.quote("mailto:"+"foo@foo-bar.de?subject=test")
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
def test_warn_mail (self):
|
||||
"""test some mailto addrs with warnings"""
|
||||
# contains non-quoted characters
|
||||
url = "calvin@users.sf.net?subject=äöü"
|
||||
resultlines = [
|
||||
"url %s" % self.quote("mailto:"+url),
|
||||
"info Verified adress: <calvin> is deliverable",
|
||||
"warning Base URL is not properly quoted",
|
||||
"valid",
|
||||
]
|
||||
self.direct("mailto:"+url, resultlines)
|
||||
url = "calvin@users.sf.net?subject=Halli hallo"
|
||||
resultlines = [
|
||||
"url %s" % self.quote("mailto:"+url),
|
||||
"info Verified adress: <calvin> is deliverable",
|
||||
"warning Base URL is not properly quoted",
|
||||
"valid",
|
||||
]
|
||||
self.direct("mailto:"+url, resultlines)
|
||||
url = self.quote("mailto:")
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"warning No adresses found",
|
||||
"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
def test_bad_mail (self):
|
||||
"""test some mailto addrs with bad syntax"""
|
||||
# ? extension forbidden in <> construct
|
||||
url = self.quote("mailto:Bastian Kleineidam "\
|
||||
"<calvin@users.sf.net?foo=bar>")
|
||||
resultlines = ["url %s" % url, "error"]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""build and return a TestSuite"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestMail))
|
||||
return suite
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
100
linkcheck/ftests/test_news.py
Normal file
100
linkcheck/ftests/test_news.py
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test news checking"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
|
||||
class TestNews (linkcheck.ftests.StandardTest):
|
||||
"""test nntp: and news: link checking"""
|
||||
|
||||
def newstest (self, url, resultlines):
|
||||
fields = ['url', 'warning', 'result', ]
|
||||
self.direct(url, resultlines, fields=fields)
|
||||
|
||||
def test_news (self):
|
||||
"""test some news links"""
|
||||
# news testing
|
||||
url = "news:comp.os.linux.misc"
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"warning No NNTP server specified, skipping this URL",
|
||||
"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
# snews
|
||||
url = "snews:de.comp.os.unix.linux.misc"
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"warning No NNTP server specified, skipping this URL",
|
||||
"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
# no group
|
||||
url = "news:"
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"warning No NNTP server specified, skipping this URL",
|
||||
"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
# illegal syntax
|
||||
url = "§$%&/´`(§%"
|
||||
resultlines = [
|
||||
"url %s" % self.quote("news:"+url),
|
||||
"warning Base URL is not properly quoted",
|
||||
"warning No NNTP server specified, skipping this URL",
|
||||
"valid",
|
||||
]
|
||||
self.newstest("news:"+url, resultlines)
|
||||
# nttp scheme with host
|
||||
url = "nntp://news.yaako.com/comp.lang.python"
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.newstest(url, resultlines)
|
||||
# article span
|
||||
url = "nntp://news.yaako.com/comp.lang.python/1-5"
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.newstest(url, resultlines)
|
||||
# host but no group
|
||||
url = "nntp://news.yaako.com/"
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"warning No newsgroup specified in NNTP URL",
|
||||
"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
# article span
|
||||
url = "news:comp.lang.python/1-5"
|
||||
resultlines = [
|
||||
"url %s" % url,
|
||||
"warning No NNTP server specified, skipping this URL",
|
||||
"valid",
|
||||
]
|
||||
self.newstest(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""build and return a TestSuite"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestNews))
|
||||
return suite
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
50
linkcheck/ftests/test_telnet.py
Normal file
50
linkcheck/ftests/test_telnet.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""test news checking"""
|
||||
# Copyright (C) 2004 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.
|
||||
|
||||
import unittest
|
||||
|
||||
import linkcheck.ftests
|
||||
|
||||
|
||||
class TestTelnet (linkcheck.ftests.StandardTest):
|
||||
"""test telnet: link checking"""
|
||||
|
||||
def test_telnet (self):
|
||||
url = "telnet:"
|
||||
resultlines = ["url %s" % url, "error"]
|
||||
self.direct(url, resultlines)
|
||||
url = "telnet://swindon.city.ac.uk"
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
url = "telnet://user@swindon.city.ac.uk"
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
url = "telnet://user:password@swindon.city.ac.uk"
|
||||
resultlines = ["url %s" % url, "valid"]
|
||||
self.direct(url, resultlines)
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""build and return a TestSuite"""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestTelnet))
|
||||
return suite
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Reference in a new issue