''' Test package for ordr.schemas ''' from pyramid.testing import DummyRequest, DummyResource def test_csrf_schema_form_with_custom_url(): ''' test for creation with custom url ''' from ordr.schemas import CSRFSchema request = DummyRequest() form = CSRFSchema.as_form(request, action='/Nudge/Nudge') assert form.action == '/Nudge/Nudge' assert form.buttons == [] def test_csrf_schema_form_with_automatic_url(): ''' test for creation with custom url ''' from ordr.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'