Ejemplo n.º 1
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())
Ejemplo n.º 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())
Ejemplo n.º 3
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()
Ejemplo n.º 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()
Ejemplo n.º 5
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}
Ejemplo n.º 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}