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.
65 lines
2.1 KiB
65 lines
2.1 KiB
''' Tests for the root resource ''' |
|
|
|
import pytest |
|
|
|
from pyramid.testing import DummyRequest, DummyResource |
|
|
|
|
|
def test_base_child_init(): |
|
from ordr.resources.helpers import BaseChildResource |
|
resource = BaseChildResource( |
|
request='some request', |
|
name='a name', |
|
parent='the parent' |
|
) |
|
assert resource.__name__ == 'a name' |
|
assert resource.__parent__ == 'the parent' |
|
assert resource.request == 'some request' |
|
|
|
|
|
def test_base_child_acl(): |
|
from ordr.resources.helpers import BaseChildResource |
|
resource = BaseChildResource( |
|
request='some request', |
|
name='a name', |
|
parent='the parent' |
|
) |
|
with pytest.raises(NotImplementedError): |
|
resource.__acl__() |
|
|
|
|
|
def test_base_child_prepare_form(): |
|
from ordr.resources.helpers import BaseChildResource |
|
from ordr.schemas.account import RegistrationSchema |
|
import deform |
|
parent = DummyResource() |
|
request = DummyRequest() |
|
resource = BaseChildResource(request, 'a name', parent) |
|
form = resource._prepare_form(RegistrationSchema) |
|
assert isinstance(form, deform.Form) |
|
assert form.action == 'http://example.com//' |
|
assert len(form.buttons) == 0 |
|
|
|
|
|
def test_base_child_prepare_form_url(): |
|
from ordr.resources.helpers import BaseChildResource |
|
from ordr.schemas.account import RegistrationSchema |
|
parent = DummyResource() |
|
request = DummyRequest() |
|
resource = BaseChildResource(request, 'a name', parent) |
|
form = resource._prepare_form(RegistrationSchema, url='/foo') |
|
assert form.action == '/foo' |
|
|
|
|
|
def test_base_child_prepare_form_settings(): |
|
from ordr.resources.helpers import BaseChildResource |
|
from ordr.schemas.account import RegistrationSchema |
|
import deform |
|
parent = DummyResource() |
|
request = DummyRequest() |
|
resource = BaseChildResource(request, 'a name', parent) |
|
settings = {'buttons': ('ok', 'cancel')} |
|
form = resource._prepare_form(RegistrationSchema, **settings) |
|
assert len(form.buttons) == 2 |
|
assert isinstance(form.buttons[0], deform.Button) |
|
assert isinstance(form.buttons[1], deform.Button)
|
|
|