Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release History
Next Release
++++++++
- Allow ints to be passed in as item IDs
- Fix bug with updating a collaboration role to owner

2.9.0 (2020-06-23)
++++++++
Expand Down
12 changes: 8 additions & 4 deletions boxsdk/object/base_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,16 @@ def update_info(self, data, params=None, headers=None, **kwargs):
:rtype:
:class:`BaseObject`
"""
# pylint:disable=no-else-return
url = self.get_url()
box_response = self._session.put(url, data=json.dumps(data), params=params, headers=headers, **kwargs)
return self.translator.translate(
session=self._session,
response_object=box_response.json(),
)
if 'expect_json_response' in kwargs and not kwargs['expect_json_response']:
return box_response.ok
else:
return self.translator.translate(
session=self._session,
response_object=box_response.json(),
)

@api_call
def delete(self, params=None, headers=None):
Expand Down
7 changes: 5 additions & 2 deletions boxsdk/object/collaboration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ def update_info(self, role=None, status=None):
:raises:
:class:`BoxAPIException` if current user doesn't have permissions to edit the collaboration.
"""
# pylint:disable=arguments-differ
# pylint:disable=arguments-differ,no-else-return
data = {}
if role:
data['role'] = role
if status:
data['status'] = status
return super(Collaboration, self).update_info(data=data)
if role == CollaborationRole.OWNER:
return super(Collaboration, self).update_info(data=data, expect_json_response=False)
else:
return super(Collaboration, self).update_info(data=data)

@api_call
def accept(self):
Expand Down
18 changes: 18 additions & 0 deletions test/unit/object/test_collaboration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ def test_update_info_returns_the_correct_response(
assert update_response.object_id == test_collaboration.object_id


def test_update_info_returns_204(
test_collaboration,
mock_box_session):
# pylint:disable=protected-access
data = {'role': CollaborationRole.OWNER, 'status': CollaborationStatus.ACCEPTED}
expected_url = test_collaboration.get_url()
mock_box_session.put.return_value.ok = True
is_success = test_collaboration.update_info(**data)
mock_box_session.put.assert_called_once_with(
expected_url,
data=json.dumps(data),
expect_json_response=False,
headers=None,
params=None,
)
assert is_success is True


def test_accept_pending_collaboration(test_collaboration, mock_box_session):
# pylint:disable=protected-access
new_status = 'accepted'
Expand Down