def test__check_permissions_check_failed(self, mock_ctx, mock_engine):
     request = Mock()
     request.has_permission.return_value = False
     document = {"_type": "Story", "_acl": ["foobar"]}
     assert es._check_permissions(request, document) is None
     mock_engine.ACLField.objectify_acl.assert_called_once_with(["foobar"])
     objectified = mock_engine.ACLField.objectify_acl()
     mock_ctx.assert_called_once_with(objectified)
     request.has_permission.assert_any_call("view", mock_ctx())
Exemple #2
0
 def test__check_permissions_check_failed(self, mock_ctx, mock_engine):
     request = Mock()
     request.has_permission.return_value = False
     document = {'_type': 'Story', '_acl': ['foobar']}
     assert es._check_permissions(request, document) is None
     mock_engine.ACLField.objectify_acl.assert_called_once_with(
         ['foobar'])
     objectified = mock_engine.ACLField.objectify_acl()
     mock_ctx.assert_called_once_with(objectified)
     request.has_permission.assert_any_call('view', mock_ctx())
 def test__check_permissions_check_succeeded(self, mock_ctx, mock_engine, mock_check):
     request = Mock()
     request.has_permission.return_value = True
     document = {"_type": "Story", "_acl": ["foobar"]}
     result = es._check_permissions(request, document)
     mock_engine.ACLField.objectify_acl.assert_called_once_with(["foobar"])
     objectified = mock_engine.ACLField.objectify_acl()
     mock_ctx.assert_called_once_with(objectified)
     request.has_permission.assert_any_call("view", mock_ctx())
     mock_check.assert_called_once_with(request, document)
     assert result == mock_check()
Exemple #4
0
 def test__check_permissions_check_succeeded(
         self, mock_ctx, mock_engine, mock_check):
     request = Mock()
     request.has_permission.return_value = True
     document = {'_type': 'Story', '_acl': ['foobar']}
     result = es._check_permissions(request, document)
     mock_engine.ACLField.objectify_acl.assert_called_once_with(
         ['foobar'])
     objectified = mock_engine.ACLField.objectify_acl()
     mock_ctx.assert_called_once_with(objectified)
     request.has_permission.assert_any_call('view', mock_ctx())
     mock_check.assert_called_once_with(request, document)
     assert result == mock_check()
 def test_check_permissions_invalid_doc(self):
     assert es._check_permissions(None, 1) == 1
     assert es._check_permissions(None, "foo") == "foo"
     assert es._check_permissions(None, {"id": 1}) == {"id": 1}
Exemple #6
0
 def test_check_permissions_invalid_doc(self):
     assert es._check_permissions(None, 1) == 1
     assert es._check_permissions(None, 'foo') == 'foo'
     assert es._check_permissions(None, {'id': 1}) == {'id': 1}