class documentation

Tests for klein.Form and associated tools.

Method test_cookieNoToken A cookie-authenticated, CSRF-protected form will return a 403 Forbidden status code when a CSRF protection token is not supplied.
Method test_cookieWithToken A cookie-authenticated, CRSF-protected form will call the form as expected.
Method test_customParameterValidation 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_customValidationHandling Form.onValidationFailureFor handles form validation failures by handing its thing a renderable form.
Method test_handling A handler for a Form with Fields receives those fields as input, as passed by an HTTP client.
Method test_handlingGET A GET handler for a Form with Fields receives query parameters matching those field names as input.
Method test_handlingJSON 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_handlingPassword From the perspective of form handling, passwords are handled like strings.
Method test_missingOptionalParameterJSON If a required Field is missing from the JSON body, its default value is used.
Method test_missingRequiredParameter If required fields are missing, a default error form is presented and the form's handler is not called.
Method test_noName A handler for a Form with a Field that doesn't have a name will return an error explaining the problem.
Method test_noSessionPOST An unauthenticated, CSRF-protected form will return a 403 Forbidden status code.
Method test_numberConstraints Number parameters have minimum and maximum validations and the object will not be called when the values exceed them.
Method test_rendering When a route requires form fields, it renders a form with those fields.
Method test_renderingEmptyForm When a form renderer specifies a submit button, no automatic submit button is rendered.
Method test_renderingExplicitSubmit When a form renderer specifies a submit button, no automatic submit button is rendered.
Method test_renderingFormGlue When a form renderer renders just the glue, none of the rest of the form is included.
Method test_renderingWithNoSessionYet When a route is rendered with no session, it sets a cookie to establish a new session.
Method test_renderLookupError RenderableForm raises MissingRenderMethod if anything attempts to look up a render method on it.
Method test_textConverter Convert a string of either type to text.
Method test_validatingParameters 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.
def test_cookieNoToken(self): (source)

A cookie-authenticated, CSRF-protected form will return a 403 Forbidden status code when a CSRF protection token is not supplied.

def test_cookieWithToken(self): (source)

A cookie-authenticated, CRSF-protected form will call the form as expected.

def test_customParameterValidation(self): (source)

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.

def test_customValidationHandling(self): (source)

Form.onValidationFailureFor handles form validation failures by handing its thing a renderable form.

def test_handling(self): (source)

A handler for a Form with Fields receives those fields as input, as passed by an HTTP client.

def test_handlingGET(self): (source)

A GET handler for a Form with Fields receives query parameters matching those field names as input.

def test_handlingJSON(self): (source)

A handler for a form with Fields receives those fields as input, as passed by an HTTP client that submits a JSON POST body.

def test_handlingPassword(self): (source)

From the perspective of form handling, passwords are handled like strings.

def test_missingOptionalParameterJSON(self): (source)

If a required Field is missing from the JSON body, its default value is used.

def test_missingRequiredParameter(self): (source)

If required fields are missing, a default error form is presented and the form's handler is not called.

def test_noName(self): (source)

A handler for a Form with a Field that doesn't have a name will return an error explaining the problem.

def test_noSessionPOST(self): (source)

An unauthenticated, CSRF-protected form will return a 403 Forbidden status code.

def test_numberConstraints(self): (source)

Number parameters have minimum and maximum validations and the object will not be called when the values exceed them.

def test_rendering(self): (source)

When a route requires form fields, it renders a form with those fields.

def test_renderingEmptyForm(self): (source)

When a form renderer specifies a submit button, no automatic submit button is rendered.

def test_renderingExplicitSubmit(self): (source)

When a form renderer specifies a submit button, no automatic submit button is rendered.

def test_renderingFormGlue(self): (source)

When a form renderer renders just the glue, none of the rest of the form is included.

def test_renderingWithNoSessionYet(self): (source)

When a route is rendered with no session, it sets a cookie to establish a new session.

def test_renderLookupError(self): (source)

RenderableForm raises MissingRenderMethod if anything attempts to look up a render method on it.

def test_textConverter(self): (source)

Convert a string of either type to text.

def test_validatingParameters(self): (source)

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.