From fcf22d7c38f6b65ef7f1b3ea3fc0e86ab5a7a9ad Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Sun, 6 Mar 2016 15:05:29 -0800 Subject: [PATCH] remove broken validate module It can probably be fixed, but quite frankly I don't think this module is even useful. --- modules/test/test_validate.py | 31 ------------------------- modules/validate.py | 43 ----------------------------------- 2 files changed, 74 deletions(-) delete mode 100644 modules/test/test_validate.py delete mode 100644 modules/validate.py diff --git a/modules/test/test_validate.py b/modules/test/test_validate.py deleted file mode 100644 index e1f5421..0000000 --- a/modules/test/test_validate.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -test_validate.py - tests for the validation module -author: mutantmonkey -""" - -import re -import unittest -from mock import MagicMock, Mock -from modules.validate import val - - -class TestValidate(unittest.TestCase): - def setUp(self): - self.phenny = MagicMock() - - def test_valid(self): - url = 'http://validator.w3.org/' - input = Mock(group=lambda x: url) - val(self.phenny, input) - - self.phenny.reply.assert_called_once_with('{0} is Valid'.format(url)) - - def test_invalid(self): - url = 'http://microsoft.com/' - input = Mock(group=lambda x: url) - val(self.phenny, input) - - out = self.phenny.reply.call_args[0][0] - m = re.match('^{0} is Invalid \(\d+ errors\)'.format(url), - out, flags=re.UNICODE) - self.assertTrue(m) diff --git a/modules/validate.py b/modules/validate.py deleted file mode 100644 index a495425..0000000 --- a/modules/validate.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python -""" -validate.py - Phenny Validation Module -Copyright 2008, Sean B. Palmer, inamidst.com -Licensed under the Eiffel Forum License 2. - -http://inamidst.com/phenny/ -""" - -import web - -def val(phenny, input): - """Check a webpage using the W3C Markup Validator.""" - if not input.group(2): - return phenny.reply("Nothing to validate.") - uri = input.group(2) - if not uri.startswith('http://'): - uri = 'http://' + uri - - path = '/check?uri=%s;output=xml' % web.quote(uri) - info = web.head('https://validator.w3.org' + path) - - result = uri + ' is ' - - if isinstance(info, list): - return phenny.say('Got HTTP response %s' % info[1]) - - if 'X-W3C-Validator-Status' in info: - result += str(info['X-W3C-Validator-Status']) - if info['X-W3C-Validator-Status'] != 'Valid': - if 'X-W3C-Validator-Errors' in info: - n = int(info['X-W3C-Validator-Errors'].split(' ')[0]) - if n != 1: - result += ' (%s errors)' % n - else: result += ' (%s error)' % n - else: result += 'Unvalidatable: no X-W3C-Validator-Status' - - phenny.reply(result) -val.rule = (['val'], r'(?i)(\S+)') -val.example = '.val http://www.w3.org/' - -if __name__ == '__main__': - print(__doc__.strip())