59 lines
2.6 KiB
Python
59 lines
2.6 KiB
Python
""" This should be the place to test the functinality of the random
|
|
stuff that has been collected in the utils package. Idealy we shuld get rid
|
|
of this random addons. """
|
|
|
|
import unittest
|
|
from utils import html_cleaner
|
|
|
|
|
|
class HtmlTestCase(unittest.TestCase):
|
|
""" Unit testcase to verify the HTML cleanup class.
|
|
|
|
It should removed unwanted syling tags an more get rid of dangerous
|
|
JavaScript elements.
|
|
"""
|
|
|
|
known_html = (
|
|
('<STRONG>Fett!</STRONG>', '<strong>Fett!</strong>'),
|
|
('<a href="link.html" onclick="do_evil()">Bad Link</a>',
|
|
'<a href="link.html">Bad Link</a>'),
|
|
('''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML><HEAD>
|
|
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
|
|
<META content="MSHTML 5.50.4919.2200" name=GENERATOR>
|
|
<STYLE></STYLE>
|
|
</HEAD>
|
|
<BODY bgColor=#ffffff>
|
|
<DIV><FONT face=Arial size=2>Hey Brad;</FONT></DIV>
|
|
<DIV><FONT face=Arial size=2></FONT> </DIV>
|
|
<DIV><FONT face=Arial size=2> 1) From your FAQ page at Webalizer.com the README
|
|
file link in question 19 to <A
|
|
href="ftp://ftp.mrunix.net/pub/webalizer/README">ftp://ftp.mrunix.net/pub/webalizer/README</A> brings
|
|
a 404 Page Not Found error message.</FONT></DIV>
|
|
<DIV><FONT face=Arial size=2></FONT> </DIV>
|
|
<DIV><FONT face=Arial size=2> 2) </FONT><FONT face=Arial size=2>My host recently
|
|
added Webalizer and I am trying to find the best way to keep the program running
|
|
correctly and to deny outsiders the ability to look at it. I would prefer not to
|
|
give others access to my stats. I do web design and at any given time have
|
|
client demos in various stages of completion and other things I'd prefer not to
|
|
have the general public see popping up in my stats. Does Webalizer have a
|
|
password protection mode or anything?</FONT></DIV>
|
|
<DIV><FONT face=Arial size=2></FONT> </DIV>
|
|
<DIV><FONT face=Arial size=2>XXXXXX XXXXXXX<BR>XXXXXXXXX Web Design<BR><A
|
|
href="http://www.xxxxxxxxxxxx.com">http://www.xxxxxxxxxxxx.com</A><BR>(xxx)
|
|
xxx-xxxx</FONT></DIV></BODY></HTML>
|
|
''',
|
|
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'
|
|
)
|
|
)
|
|
|
|
def test_html_cleaner(self):
|
|
"""Ugly HTML Code has been made tidy"""
|
|
cleaner = html_cleaner.HtmlCleaner()
|
|
for original, tidy in self.known_html:
|
|
self.assertEqual(cleaner.clean_html(original), tidy)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|