class TestForms(SynchronousTestCase): (source)
Tests for klein.Form
and associated tools.
Method | test_cookie |
A cookie-authenticated, CSRF-protected form will return a 403 Forbidden status code when a CSRF protection token is not supplied. |
Method | test_cookie |
A cookie-authenticated, CRSF-protected form will call the form as expected. |
Method | test_custom |
When a custom parameter fails to validate by raising ValueError - for example, a non-number passed to a numeric Field, the request fails with a 400 and the default validation failure handler displays a form which explains the error. |
Method | test_custom |
Form.onValidationFailureFor handles form validation failures by handing its thing a renderable form. |
Method | test |
A handler for a Form with Fields receives those fields as input, as passed by an HTTP client. |
Method | test_handling |
A GET handler for a Form with Fields receives query parameters matching those field names as input. |
Method | test_handling |
A handler for a form with Fields receives those fields as input, as passed by an HTTP client that submits a JSON POST body. |
Method | test_handling |
From the perspective of form handling, passwords are handled like strings. |
Method | test_missing |
If a required Field is missing from the JSON body, its default value is used. |
Method | test_missing |
If required fields are missing, a default error form is presented and the form's handler is not called. |
Method | test_no |
A handler for a Form with a Field that doesn't have a name will return an error explaining the problem. |
Method | test_no |
An unauthenticated, CSRF-protected form will return a 403 Forbidden status code. |
Method | test_number |
Number parameters have minimum and maximum validations and the object will not be called when the values exceed them. |
Method | test |
When a route requires form fields, it renders a form with those fields. |
Method | test_rendering |
When a form renderer specifies a submit button, no automatic submit button is rendered. |
Method | test_rendering |
When a form renderer specifies a submit button, no automatic submit button is rendered. |
Method | test_rendering |
When a form renderer renders just the glue, none of the rest of the form is included. |
Method | test_rendering |
When a route is rendered with no session, it sets a cookie to establish a new session. |
Method | test_render |
RenderableForm raises MissingRenderMethod if anything attempts to look up a render method on it. |
Method | test_text |
Convert a string of either type to text. |
Method | test_validating |
When a parameter fails to validate - for example, a non-number passed to a numeric Field, the request fails with a 400 and the default validation failure handler displays a form which explains the error. |
A cookie-authenticated, CSRF-protected form will return a 403 Forbidden status code when a CSRF protection token is not supplied.
When a custom parameter fails to validate by raising ValueError - for example, a non-number passed to a numeric Field, the request fails with a 400 and the default validation failure handler displays a form which explains the error.
Form.onValidationFailureFor
handles form validation failures by handing its thing a renderable form.
A handler for a form with Fields receives those fields as input, as passed by an HTTP client that submits a JSON POST body.
If required fields are missing, a default error form is presented and the form's handler is not called.
A handler for a Form with a Field that doesn't have a name will return an error explaining the problem.
Number parameters have minimum and maximum validations and the object will not be called when the values exceed them.