mirror of
https://github.com/kakwa/ldapcherry
synced 2025-07-04 20:37:48 +02:00
adding html validation in ubit tests
This commit is contained in:
parent
d9031f0994
commit
5d7f6ee12c
2 changed files with 274 additions and 0 deletions
|
@ -6,6 +6,10 @@ from __future__ import unicode_literals
|
|||
|
||||
import pytest
|
||||
import sys
|
||||
import subprocess
|
||||
from tempfile import NamedTemporaryFile as tempfile
|
||||
import re
|
||||
|
||||
from sets import Set
|
||||
from ldapcherry import LdapCherry
|
||||
from ldapcherry.exceptions import *
|
||||
|
@ -46,6 +50,24 @@ def loadconf(configfile, instance):
|
|||
cherrypy.config.update(configfile)
|
||||
instance.reload(app.config)
|
||||
|
||||
class HtmlValidationFailed(Exception):
|
||||
def __init__(self, out):
|
||||
self.errors = out
|
||||
|
||||
def htmlvalidator(page):
|
||||
f = tempfile()
|
||||
stdout = tempfile()
|
||||
f.write(page.encode("utf-8"))
|
||||
f.seek(0)
|
||||
ret = subprocess.call(['./tests/html_validator.py', '-h', f.name], stdout=stdout)
|
||||
stdout.seek(0)
|
||||
out = stdout.read()
|
||||
f.close()
|
||||
stdout.close()
|
||||
print(out)
|
||||
if not re.search(r'Error:.*', out) is None:
|
||||
raise HtmlValidationFailed(out)
|
||||
|
||||
class BadModule():
|
||||
pass
|
||||
|
||||
|
@ -161,6 +183,15 @@ class TestError(object):
|
|||
app._modify(modify_form)
|
||||
app._deleteuser('test')
|
||||
|
||||
def testHtml(self):
|
||||
app = LdapCherry()
|
||||
loadconf('./tests/cfg/ldapcherry_test.ini', app)
|
||||
pages = [
|
||||
app.signin(),
|
||||
]
|
||||
for page in pages:
|
||||
htmlvalidator(page)
|
||||
|
||||
def testLogger(self):
|
||||
app = LdapCherry()
|
||||
loadconf('./tests/cfg/ldapcherry.ini', app)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue