Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trash endpoint #332

Merged
merged 26 commits into from Oct 9, 2018
Merged

trash endpoint #332

merged 26 commits into from Oct 9, 2018

Conversation

carycheng
Copy link

No description provided.

@boxcla
Copy link

boxcla commented Aug 21, 2018

Hi @carycheng, thanks for the pull request. Before we can merge it, we need you to sign our Contributor License Agreement. You can do so electronically here: http://opensource.box.com/cla

Once you have signed, just add a comment to this pull request saying, "CLA signed". Thanks!

@coveralls
Copy link

coveralls commented Oct 4, 2018

Pull Request Test Coverage Report for Build 1107

  • 35 of 35 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.09%) to 94.614%

Totals Coverage Status
Change from base Build 1095: 0.09%
Covered Lines: 2108
Relevant Lines: 2228

💛 - Coveralls

boxsdk/client/client.py Show resolved Hide resolved
class Trash(BaseEndpoint):
"""Box API endpoint for performing trash related actions in Box."""

def get_from_trash(self, item, fields=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should probably have a better name — client.trash().get_from_trash() stutters a bit

Get item from trash.

:param item:
The :class:`File` or :class:`Folder` or :class:`WebLink` object to restore from trash.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is incorrect; the item is not restored by this method

:param item:
The :class:`File` or :class:`Folder` or :class:`WebLink` object to restore from trash.
:type item:
:class:`File` or :class:`Folder` or :class:`WebLink`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could just do :class:`Item` here

:returns:
A trashed :class:`File`, :class:`Folder`, or :class:`WebLink` object.
:rtype:
:class:`File`, :class:`Folder`, or :class:`WebLink`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also probably be :class:`Item`


def test_permanently_delete(test_item_and_response, test_trash, mock_box_session):
# pylint:disable=redefined-outer-name, protected-access
test_item, mock_item_response = test_item_and_response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mock response probably isn't really much like what the API would return for this case; can we align with the correct response? It should have a 204 status code with no body

test/unit/object/test_trash.py Show resolved Hide resolved
test/unit/object/test_trash.py Show resolved Hide resolved
trashed_items = test_trash.get_trashed_items(fields=['name'])
trashed_item = trashed_items.next()
mock_box_session.get.assert_called_once_with(expected_url, params={'fields': 'name', 'offset': None})
assert trashed_item['type'] == mock_trash['type']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also assert about the class of the returned item

trashed_item = trashed_items.next()
mock_box_session.get.assert_called_once_with(expected_url, params={'fields': 'name', 'offset': None})
assert trashed_item['type'] == mock_trash['type']
assert trashed_item['id'] == mock_trash['id']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't really verify that the item works correctly; why does this test use ['id'] notation (which would pass even if the item never got translated) instead of .id (which requires that the item got translated)?

Copy link
Contributor

@mattwiller mattwiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small comment, otherwise looks good to me!

class Trash(BaseEndpoint):
"""Box API endpoint for performing trash related actions in Box."""

def get_item_info(self, item, fields=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_info isn't really necessary in the name; most things that the SDK gets are "information"

@carycheng carycheng merged commit d79aa7c into master Oct 9, 2018
@carycheng carycheng deleted the trash_v2 branch October 9, 2018 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants