Jacek Medrzycki
2007-03-26 15:10:25 UTC
I have written a small test that validates forms using external
validator on w3.org page.
As it's not typical unit test and I'm in doubts of how such test should
look like, it's more a proposal to discussion than final solution,
thought it works.
Currently it checks login form, main form and some view and listbox
forms. As any form of its type is rendered by the same renderer, it
seems that it is enough to check some forms, not all - probably the
representative probe to make sure all field types are included in test.
For now it checks Person_view and Person_viewProfile,
PersonModule_viewPersonList, Organisation_view and
OrganisationModule_viewOrganisationList, but it rather an example.
Perhaps other forms should be taken into account.
test_03_StandardForms checks all forms defined in
getFormsToValidateList() and launches the validator for each form. It
gatheres all errors and fails if the error list is not empty, so all
forms are tested. Test results are shown in the exception message (if
the verbose is set to false, only form names for which validation failed
are shown)
The heart of the test is W3FormValidator class that fires the
validator.w3.org page and parses the result. Its validate_form method
gets a page source code and then parses the W3 org validator output and
returns a list of tuples: line, column and error message.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testW3Conformance.py
Type: text/x-python
Size: 5991 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20070326/b9f5ee8d/attachment.py>
validator on w3.org page.
As it's not typical unit test and I'm in doubts of how such test should
look like, it's more a proposal to discussion than final solution,
thought it works.
Currently it checks login form, main form and some view and listbox
forms. As any form of its type is rendered by the same renderer, it
seems that it is enough to check some forms, not all - probably the
representative probe to make sure all field types are included in test.
For now it checks Person_view and Person_viewProfile,
PersonModule_viewPersonList, Organisation_view and
OrganisationModule_viewOrganisationList, but it rather an example.
Perhaps other forms should be taken into account.
test_03_StandardForms checks all forms defined in
getFormsToValidateList() and launches the validator for each form. It
gatheres all errors and fails if the error list is not empty, so all
forms are tested. Test results are shown in the exception message (if
the verbose is set to false, only form names for which validation failed
are shown)
The heart of the test is W3FormValidator class that fires the
validator.w3.org page and parses the result. Its validate_form method
gets a page source code and then parses the W3 org validator output and
returns a list of tuples: line, column and error message.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testW3Conformance.py
Type: text/x-python
Size: 5991 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20070326/b9f5ee8d/attachment.py>