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