From 4c75057de15a2e0f8405f4ccec27893924200778 Mon Sep 17 00:00:00 2001 From: LoopThrough-i-j Date: Wed, 24 Feb 2021 05:36:45 +0530 Subject: [PATCH] dropbox-bot: Update to support dropbox>=11.0.0. Changes in dropox version >= 11.0 broke the dropbox bot. The required fixes are mentioned at: https://github.com/dropbox/dropbox-sdk-python/blob/main/UPGRADING.md#upgrading-from-v10xx-to-v1100 --- .../bots/dropbox_share/dropbox_share.py | 2 +- .../bots/dropbox_share/requirements.txt | 3 +- .../bots/dropbox_share/test_dropbox_share.py | 34 +++++++++---------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/dropbox_share/dropbox_share.py b/zulip_bots/zulip_bots/bots/dropbox_share/dropbox_share.py index c38d6c5..0b2392d 100644 --- a/zulip_bots/zulip_bots/bots/dropbox_share/dropbox_share.py +++ b/zulip_bots/zulip_bots/bots/dropbox_share/dropbox_share.py @@ -1,4 +1,4 @@ -from dropbox.dropbox import Dropbox +from dropbox import Dropbox from typing import Any, Dict, List, Tuple import re diff --git a/zulip_bots/zulip_bots/bots/dropbox_share/requirements.txt b/zulip_bots/zulip_bots/bots/dropbox_share/requirements.txt index 2e3fc1e..c9fe58e 100644 --- a/zulip_bots/zulip_bots/bots/dropbox_share/requirements.txt +++ b/zulip_bots/zulip_bots/bots/dropbox_share/requirements.txt @@ -1,2 +1 @@ -# Tests fail with Dropbox >= 11. -dropbox==10.* +dropbox diff --git a/zulip_bots/zulip_bots/bots/dropbox_share/test_dropbox_share.py b/zulip_bots/zulip_bots/bots/dropbox_share/test_dropbox_share.py index 7c637df..7aaade1 100644 --- a/zulip_bots/zulip_bots/bots/dropbox_share/test_dropbox_share.py +++ b/zulip_bots/zulip_bots/bots/dropbox_share/test_dropbox_share.py @@ -84,20 +84,20 @@ class TestDropboxBot(BotTestCase, DefaultTests): def test_dbx_ls_root(self): bot_response = " - [foo](https://www.dropbox.com/home/foo)\n"\ " - [boo](https://www.dropbox.com/home/boo)" - with patch('dropbox.dropbox.Dropbox.files_list_folder', side_effect=get_root_files_list), \ + with patch('dropbox.Dropbox.files_list_folder', side_effect=get_root_files_list), \ self.mock_config_info(self.config_info): self.verify_reply("ls", bot_response) def test_dbx_ls_folder(self): bot_response = " - [moo](https://www.dropbox.com/home/foo/moo)\n"\ " - [noo](https://www.dropbox.com/home/foo/noo)" - with patch('dropbox.dropbox.Dropbox.files_list_folder', side_effect=get_folder_files_list), \ + with patch('dropbox.Dropbox.files_list_folder', side_effect=get_folder_files_list), \ self.mock_config_info(self.config_info): self.verify_reply("ls foo", bot_response) def test_dbx_ls_empty(self): bot_response = '`No files available`' - with patch('dropbox.dropbox.Dropbox.files_list_folder', side_effect=get_empty_files_list), \ + with patch('dropbox.Dropbox.files_list_folder', side_effect=get_empty_files_list), \ self.mock_config_info(self.config_info): self.verify_reply("ls", bot_response) @@ -105,66 +105,66 @@ class TestDropboxBot(BotTestCase, DefaultTests): bot_response = "Please provide a correct folder path\n"\ "Usage: `ls ` to list folders in directory\n"\ "or simply `ls` for listing folders in the root directory" - with patch('dropbox.dropbox.Dropbox.files_list_folder', side_effect=Exception()), \ + with patch('dropbox.Dropbox.files_list_folder', side_effect=Exception()), \ self.mock_config_info(self.config_info): self.verify_reply("ls", bot_response) def test_dbx_mkdir(self): bot_response = "CREATED FOLDER: [foo](https://www.dropbox.com/home/foo)" - with patch('dropbox.dropbox.Dropbox.files_create_folder', side_effect=create_file), \ + with patch('dropbox.Dropbox.files_create_folder', side_effect=create_file), \ self.mock_config_info(self.config_info): self.verify_reply('mkdir foo', bot_response) def test_dbx_mkdir_error(self): bot_response = "Please provide a correct folder path and name.\n"\ "Usage: `mkdir ` to create a folder." - with patch('dropbox.dropbox.Dropbox.files_create_folder', side_effect=Exception()), \ + with patch('dropbox.Dropbox.files_create_folder', side_effect=Exception()), \ self.mock_config_info(self.config_info): self.verify_reply('mkdir foo/bar', bot_response) def test_dbx_rm(self): bot_response = "DELETED File/Folder : [foo](https://www.dropbox.com/home/foo)" - with patch('dropbox.dropbox.Dropbox.files_delete', side_effect=create_file), \ + with patch('dropbox.Dropbox.files_delete', side_effect=create_file), \ self.mock_config_info(self.config_info): self.verify_reply('rm foo', bot_response) def test_dbx_rm_error(self): bot_response = "Please provide a correct folder path and name.\n"\ "Usage: `rm ` to delete a folder in root directory." - with patch('dropbox.dropbox.Dropbox.files_delete', side_effect=Exception()), \ + with patch('dropbox.Dropbox.files_delete', side_effect=Exception()), \ self.mock_config_info(self.config_info): self.verify_reply('rm foo', bot_response) def test_dbx_write(self): bot_response = "Written to file: [foo](https://www.dropbox.com/home/foo)" - with patch('dropbox.dropbox.Dropbox.files_upload', side_effect=create_file), \ + with patch('dropbox.Dropbox.files_upload', side_effect=create_file), \ self.mock_config_info(self.config_info): self.verify_reply('write foo boo', bot_response) def test_dbx_write_error(self): bot_response = "Incorrect file path or file already exists.\n"\ "Usage: `write CONTENT`" - with patch('dropbox.dropbox.Dropbox.files_upload', side_effect=Exception()), \ + with patch('dropbox.Dropbox.files_upload', side_effect=Exception()), \ self.mock_config_info(self.config_info): self.verify_reply('write foo boo', bot_response) def test_dbx_read(self): bot_response = "**foo** :\nboo" - with patch('dropbox.dropbox.Dropbox.files_download', side_effect=download_file), \ + with patch('dropbox.Dropbox.files_download', side_effect=download_file), \ self.mock_config_info(self.config_info): self.verify_reply('read foo', bot_response) def test_dbx_read_error(self): bot_response = "Please provide a correct file path\n"\ "Usage: `read ` to read content of a file" - with patch('dropbox.dropbox.Dropbox.files_download', side_effect=Exception()), \ + with patch('dropbox.Dropbox.files_download', side_effect=Exception()), \ self.mock_config_info(self.config_info): self.verify_reply('read foo', bot_response) def test_dbx_search(self): bot_response = " - [foo](https://www.dropbox.com/home/foo)\n"\ " - [fooboo](https://www.dropbox.com/home/fooboo)" - with patch('dropbox.dropbox.Dropbox.files_search', side_effect=search_files), \ + with patch('dropbox.Dropbox.files_search', side_effect=search_files), \ self.mock_config_info(self.config_info): self.verify_reply('search foo', bot_response) @@ -172,7 +172,7 @@ class TestDropboxBot(BotTestCase, DefaultTests): bot_response = "No files/folders found matching your query.\n"\ "For file name searching, the last token is used for prefix matching"\ " (i.e. “bat c” matches “bat cave” but not “batman car”)." - with patch('dropbox.dropbox.Dropbox.files_search', side_effect=get_empty_search_result), \ + with patch('dropbox.Dropbox.files_search', side_effect=get_empty_search_result), \ self.mock_config_info(self.config_info): self.verify_reply('search boo --fd foo', bot_response) @@ -180,20 +180,20 @@ class TestDropboxBot(BotTestCase, DefaultTests): bot_response = "Usage: `search query --mr 10 --fd `\n"\ "Note:`--mr ` is optional and is used to specify maximun results.\n"\ " `--fd ` to search in specific folder." - with patch('dropbox.dropbox.Dropbox.files_search', side_effect=Exception()), \ + with patch('dropbox.Dropbox.files_search', side_effect=Exception()), \ self.mock_config_info(self.config_info): self.verify_reply('search foo', bot_response) def test_dbx_share(self): bot_response = 'http://www.foo.com/boo' - with patch('dropbox.dropbox.Dropbox.sharing_create_shared_link', side_effect=get_shared_link), \ + with patch('dropbox.Dropbox.sharing_create_shared_link', side_effect=get_shared_link), \ self.mock_config_info(self.config_info): self.verify_reply('share boo', bot_response) def test_dbx_share_error(self): bot_response = "Please provide a correct file name.\n"\ "Usage: `share `" - with patch('dropbox.dropbox.Dropbox.sharing_create_shared_link', side_effect=Exception()), \ + with patch('dropbox.Dropbox.sharing_create_shared_link', side_effect=Exception()), \ self.mock_config_info(self.config_info): self.verify_reply('share boo', bot_response)