''' Test package for ordr2.schemas ''' from pyramid.testing import DummyRequest, DummyResource from .. import app_config def test_csrf_schema_form_with_custom_url(app_config): ''' test for creation with custom url ''' from ordr2.schemas import CSRFSchema request = DummyRequest() form = CSRFSchema.as_form(request, url='/Nudge/Nudge') assert form.action == '/Nudge/Nudge' assert form.buttons == [] def test_csrf_schema_form_with_automatic_url(app_config): ''' test for creation with custom url ''' from deform.form import Button from ordr2.schemas import CSRFSchema root = DummyResource() context = DummyResource('Crunchy', root) request = DummyRequest(context=context, view_name='Frog') form = CSRFSchema.as_form(request, buttons=['submit']) assert 'http://example.com/Crunchy/Frog' == form.action assert len(form.buttons) == 1 assert form.buttons[0].type == 'submit'