CPI Ordering System (the old version)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

32 lines
943 B

''' 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'