def revisions(self, path, **kwargs): response = yield from self.make_request( 'GET', self.build_url('revisions', 'auto', path.full_path, rev_limit=250), expects=(200, ), throws=exceptions.RevisionsError) data = yield from response.json() return [ DropboxRevision(item) for item in data if not item.get('is_deleted') ]
def test_revision_metadata(self, revision_fixtures): item = revision_fixtures['file_revision_metadata']['entries'][0] data = DropboxRevision(item) assert data.version_identifier == 'revision' assert data.version == '95bb27d11' assert data.modified == '2017-08-25T17:36:44Z' assert data.modified_utc == '2017-08-25T17:36:44+00:00' assert data.extra == { 'id': 'id:jki_ZJstdSAAAAAAAAAABw', 'revisionId': '95bb27d11' } assert data.serialized() == { 'extra': { 'id': 'id:jki_ZJstdSAAAAAAAAAABw', 'revisionId': '95bb27d11' }, 'modified': '2017-08-25T17:36:44Z', 'modified_utc': '2017-08-25T17:36:44+00:00', 'version': '95bb27d11', 'versionIdentifier': 'revision' } assert data.json_api_serialized() == { 'id': '95bb27d11', 'type': 'file_versions', 'attributes': { 'extra': { 'revisionId': '95bb27d11', 'id': 'id:jki_ZJstdSAAAAAAAAAABw' }, 'version': '95bb27d11', 'modified': '2017-08-25T17:36:44Z', 'modified_utc': '2017-08-25T17:36:44+00:00', 'versionIdentifier': 'revision' } }
async def test_get_revisions(self, provider, revision_fixtures): path = WaterButlerPath('/pfile', prepend=provider.folder) url = provider.build_url('files', 'list_revisions') data = {'path': path.full_path.rstrip('/'), 'limit': 100} aiohttpretty.register_json_uri( 'POST', url, data=data, body=revision_fixtures['file_revision_metadata']) result = await provider.revisions(path) expected = [ DropboxRevision(item) for item in revision_fixtures['file_revision_metadata']['entries'] ] assert result == expected assert len(result) == 3
async def revisions(self, path: WaterButlerPath, **kwargs) -> typing.List[DropboxRevision]: # Dropbox v2 API limits the number of revisions returned to a maximum # of 100, default 10. Previously we had set the limit to 250. data = await self.dropbox_request( self.build_url('files', 'list_revisions'), { 'path': path.full_path.rstrip('/'), 'limit': 100 }, throws=exceptions.RevisionsError, ) if data['is_deleted'] is True: raise exceptions.RevisionsError( "Could not retrieve '{}'".format(path), code=HTTPStatus.NOT_FOUND, ) if data['is_deleted']: return [] return [DropboxRevision(item) for item in data['entries']]