Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #54 from postatum/96310712_count_error
Browse files Browse the repository at this point in the history
Fix apply_privacy wrapper
  • Loading branch information
jstoiko committed Jun 8, 2015
2 parents 2387c4c + 9688933 commit 84a11fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nefertari/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def __call__(self, **kwargs):
return result
data = result.get('data', result)

if data:
if data and isinstance(data, (dict, list)):
self.is_admin = kwargs.get('is_admin')
if self.is_admin is None:
user = getattr(self.request, 'user', None)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ def test_apply_privacy_not_dict(self, mock_eng):
result='foo', is_admin=True)
assert filtered == 'foo'

@patch('nefertari.wrappers.engine')
def test_apply_privacy_nested_data_not_dict(self, mock_eng):
request = Mock(user=Mock())
assert wrappers.apply_privacy(request)(
result={'data': 'foo'}, is_admin=True) == {'data': 'foo'}
assert wrappers.apply_privacy(request)(
result={'data': 1}, is_admin=True) == {'data': 1}

@patch('nefertari.wrappers.engine')
def test_apply_privacy_item_admin_calculated(self, mock_eng):
document_cls = Mock(
Expand Down

0 comments on commit 84a11fa

Please sign in to comment.