def test_get_item_raises_when_annotation_is_not_found( self, storage, pyramid_request): factory = AnnotationRoot(pyramid_request) storage.fetch_annotation.return_value = None with pytest.raises(KeyError): factory['123']
def test_get_item_has_right_links_service(self, pyramid_request, storage, links_service): factory = AnnotationRoot(pyramid_request) storage.fetch_annotation.return_value = mock.Mock() resource = factory['123'] assert resource.links_service == links_service
def test_get_item_resource_has_right_annotation(self, pyramid_request, storage): factory = AnnotationRoot(pyramid_request) storage.fetch_annotation.return_value = mock.Mock() resource = factory['123'] assert resource.annotation == storage.fetch_annotation.return_value
def test_get_item_returns_annotation_resource(self, pyramid_request, storage): factory = AnnotationRoot(pyramid_request) storage.fetch_annotation.return_value = mock.Mock() resource = factory['123'] assert isinstance(resource, AnnotationContext)
def test_get_item_has_right_group_service(self, pyramid_request, storage, group_service): factory = AnnotationRoot(pyramid_request) storage.fetch_annotation.return_value = mock.Mock() resource = factory["123"] assert resource.group_service == group_service
def test_it_does_not_assign_create_permission_without_authenticated_user( self, set_permissions, pyramid_request): set_permissions() context = AnnotationRoot(pyramid_request) assert not pyramid_request.has_permission("create", context)
def test_it_assigns_create_permission_to_authenticated_request( self, set_permissions, pyramid_request): set_permissions("acct:adminuser@foo", principals=[pyramid.security.Authenticated]) context = AnnotationRoot(pyramid_request) assert pyramid_request.has_permission("create", context)
def test_it_assigns_create_permission_to_authenticated_request( self, pyramid_config, pyramid_request): policy = pyramid.authorization.ACLAuthorizationPolicy() pyramid_config.testing_securitypolicy( 'acct:adminuser@foo', groupids=[pyramid.security.Authenticated]) pyramid_config.set_authorization_policy(policy) context = AnnotationRoot(pyramid_request) assert pyramid_request.has_permission('create', context)
def test_it_does_not_assign_create_permission_without_authenticated_user( self, pyramid_config, pyramid_request): policy = pyramid.authorization.ACLAuthorizationPolicy() pyramid_config.testing_securitypolicy( None, groupids=[pyramid.security.Everyone]) pyramid_config.set_authorization_policy(policy) context = AnnotationRoot(pyramid_request) assert not pyramid_request.has_permission('create', context)
def test_get_item_fetches_annotation(self, pyramid_request, storage): factory = AnnotationRoot(pyramid_request) factory['123'] storage.fetch_annotation.assert_called_once_with( pyramid_request.db, '123')