Skip to content

Commit

Permalink
Merge pull request #376 from MrCreosote/master
Browse files Browse the repository at this point in the history
Handle at_least toggle in api translation layer
  • Loading branch information
MrCreosote committed Jul 23, 2020
2 parents 1aa7501 + 2300954 commit be83158
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/SampleService/core/api_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ def acl_delta_from_dict(d: Dict[str, Any]) -> SampleACLDelta:
_get_acl(d, 'write'),
_get_acl(d, 'read'),
_get_acl(d, 'remove'),
pub)
pub,
bool(d.get('at_least')))


def _get_acl(acls, type_):
Expand Down
14 changes: 9 additions & 5 deletions test/core/api_translation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,18 @@ def _acls_from_dict_fail(d, expected):

def test_acl_delta_from_dict():
assert acl_delta_from_dict({}) == SampleACLDelta()
assert acl_delta_from_dict({'public_read': 0}) == SampleACLDelta()
assert acl_delta_from_dict({'public_read': 1}) == SampleACLDelta(public_read=True)
assert acl_delta_from_dict({'public_read': -1}) == SampleACLDelta(public_read=False)
assert acl_delta_from_dict({'public_read': -50}) == SampleACLDelta(public_read=False)
assert acl_delta_from_dict({'public_read': 0, 'at_least': 0}) == SampleACLDelta()
assert acl_delta_from_dict({'public_read': 1, 'at_least': None}) == SampleACLDelta(
public_read=True)
assert acl_delta_from_dict({'public_read': -1, 'at_least': 1}) == SampleACLDelta(
public_read=False, at_least=True)
assert acl_delta_from_dict({'public_read': -50, 'at_least': -50}) == SampleACLDelta(
public_read=False, at_least=True)
assert acl_delta_from_dict({
'read': [],
'admin': ['whee', 'whoo'],
'public_read': None}) == SampleACLDelta([UserID('whee'), UserID('whoo')])
'public_read': None,
'at_least': 100}) == SampleACLDelta([UserID('whee'), UserID('whoo')], at_least=True)
assert acl_delta_from_dict({
'read': ['a', 'b'],
'write': ['c'],
Expand Down

0 comments on commit be83158

Please sign in to comment.