'Test cleaning of urls'

def test_clean_url(self):

    log = logging.getLogger(__name__)
    test = namedtuple('test', 'expected_result    dirty    clean')
    url_tests = [test(True, 'https://subdomain.domain.tld/endpoint', 'https://subdomain.domain.tld/endpoint'), test(True, 'http://www.example.com/folder/', 'http://www.example.com/folder/'), test(True, 'google.com/xml.rpc', 'http://google.com/xml.rpc'), test(True, 'google.com', 'http://google.com/'), test(True, 'scgi:///home/user/.config/path/socket', 'scgi:///home/user/.config/path/socket'), test(True, None, ''), test(False, 'https://subdomain.domain.tld/endpoint', 'http://subdomain.domain.tld/endpoint'), test(False, 'http://subdomain.domain.tld/endpoint', 'https://subdomain.domain.tld/endpoint'), test(False, 'google.com/xml.rpc', 'google.com/xml.rpc'), test(False, 'google.com', 'https://google.com/'), test(False, 'http://www.example.com/folder/', 'http://www.example.com/folder'), test(False, 'scgi:///home/user/.config/path/socket', 'scgi:///home/user/.config/path/socket/'), test(AttributeError, 1, 1)]
    for test_url in url_tests:
        if issubclass(type(Exception), type(test_url.expected_result)):
            with self.assertRaises(test_url.expected_result):
                self.assertEqual(config.clean_url(test_url.dirty), test_url.clean)
        elif (test_url.expected_result is True):
            self.assertEqual(config.clean_url(test_url.dirty), test_url.clean)
        elif (test_url.expected_result is False):
            self.assertNotEqual(config.clean_url(test_url.dirty), test_url.clean)
        else:
            log.error('Test    not    defined    for    %s', test_url)
