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.
 
 
 
 
 

39 lines
1.2 KiB

''' Tests for ordr2.resources.account '''
import pytest
def test_account_resource_init():
''' test __init__ function of base resource '''
from pyramid.testing import DummyRequest
from ordr2.resources import AccountResource, RootResource
request = DummyRequest(user='Eric Idle')
root = RootResource(request)
resource = AccountResource('resource name', root)
assert resource.__name__ == 'resource name'
assert resource.__parent__ == root
assert resource.request == request
assert resource.model == request.user
def test_account_resource_acl():
''' test __acl__ function of base resource '''
from pyramid.security import Allow, Authenticated, Deny, Everyone, DENY_ALL
from pyramid.testing import DummyRequest
from ordr2.resources import AccountResource, RootResource
request = DummyRequest(user=None)
root = RootResource(request)
resource = AccountResource('resource name', root)
assert resource.__acl__() == [
(Allow, Everyone, 'login'),
(Allow, Everyone, 'logout'),
(Deny, Authenticated, 'register'),
(Allow, Everyone, 'register'),
(Allow, Authenticated, 'settings'),
DENY_ALL
]