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.
38 lines
1.0 KiB
38 lines
1.0 KiB
''' Tests for the root resource ''' |
|
|
|
import pytest |
|
|
|
|
|
def test_root_init(): |
|
from ordr.resources import RootResource |
|
root = RootResource('request') |
|
assert root.__name__ is None |
|
assert root.__parent__ is None |
|
assert root.request == 'request' |
|
|
|
|
|
def test_root_acl(): |
|
from pyramid.security import Allow, Everyone, DENY_ALL |
|
from ordr.resources import RootResource |
|
root = RootResource(None) |
|
assert root.__acl__() == [(Allow, Everyone, 'view'), DENY_ALL] |
|
|
|
|
|
def test_root_getitem(): |
|
from ordr.resources import RootResource |
|
from ordr.resources.account import RegistrationResource |
|
|
|
root = RootResource(None) |
|
child = root['register'] |
|
|
|
assert isinstance(child, RegistrationResource) |
|
assert child.__name__ == 'register' |
|
assert child.__parent__ == root |
|
assert child.request == root.request |
|
|
|
|
|
def test_root_getitem_raises_error(): |
|
from ordr.resources import RootResource |
|
root = RootResource(None) |
|
with pytest.raises(KeyError): |
|
root['unknown child name']
|
|
|