Skip to content

Commit 4c75057

Browse files
LoopThrough-i-jtimabbott
authored andcommitted
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
1 parent 424404d commit 4c75057

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

zulip_bots/zulip_bots/bots/dropbox_share/dropbox_share.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dropbox.dropbox import Dropbox
1+
from dropbox import Dropbox
22
from typing import Any, Dict, List, Tuple
33
import re
44

Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# Tests fail with Dropbox >= 11.
2-
dropbox==10.*
1+
dropbox

zulip_bots/zulip_bots/bots/dropbox_share/test_dropbox_share.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -84,116 +84,116 @@ def test_bot_responds_to_empty_message(self):
8484
def test_dbx_ls_root(self):
8585
bot_response = " - [foo](https://www.dropbox.com/home/foo)\n"\
8686
" - [boo](https://www.dropbox.com/home/boo)"
87-
with patch('dropbox.dropbox.Dropbox.files_list_folder', side_effect=get_root_files_list), \
87+
with patch('dropbox.Dropbox.files_list_folder', side_effect=get_root_files_list), \
8888
self.mock_config_info(self.config_info):
8989
self.verify_reply("ls", bot_response)
9090

9191
def test_dbx_ls_folder(self):
9292
bot_response = " - [moo](https://www.dropbox.com/home/foo/moo)\n"\
9393
" - [noo](https://www.dropbox.com/home/foo/noo)"
94-
with patch('dropbox.dropbox.Dropbox.files_list_folder', side_effect=get_folder_files_list), \
94+
with patch('dropbox.Dropbox.files_list_folder', side_effect=get_folder_files_list), \
9595
self.mock_config_info(self.config_info):
9696
self.verify_reply("ls foo", bot_response)
9797

9898
def test_dbx_ls_empty(self):
9999
bot_response = '`No files available`'
100-
with patch('dropbox.dropbox.Dropbox.files_list_folder', side_effect=get_empty_files_list), \
100+
with patch('dropbox.Dropbox.files_list_folder', side_effect=get_empty_files_list), \
101101
self.mock_config_info(self.config_info):
102102
self.verify_reply("ls", bot_response)
103103

104104
def test_dbx_ls_error(self):
105105
bot_response = "Please provide a correct folder path\n"\
106106
"Usage: `ls <foldername>` to list folders in directory\n"\
107107
"or simply `ls` for listing folders in the root directory"
108-
with patch('dropbox.dropbox.Dropbox.files_list_folder', side_effect=Exception()), \
108+
with patch('dropbox.Dropbox.files_list_folder', side_effect=Exception()), \
109109
self.mock_config_info(self.config_info):
110110
self.verify_reply("ls", bot_response)
111111

112112
def test_dbx_mkdir(self):
113113
bot_response = "CREATED FOLDER: [foo](https://www.dropbox.com/home/foo)"
114-
with patch('dropbox.dropbox.Dropbox.files_create_folder', side_effect=create_file), \
114+
with patch('dropbox.Dropbox.files_create_folder', side_effect=create_file), \
115115
self.mock_config_info(self.config_info):
116116
self.verify_reply('mkdir foo', bot_response)
117117

118118
def test_dbx_mkdir_error(self):
119119
bot_response = "Please provide a correct folder path and name.\n"\
120120
"Usage: `mkdir <foldername>` to create a folder."
121-
with patch('dropbox.dropbox.Dropbox.files_create_folder', side_effect=Exception()), \
121+
with patch('dropbox.Dropbox.files_create_folder', side_effect=Exception()), \
122122
self.mock_config_info(self.config_info):
123123
self.verify_reply('mkdir foo/bar', bot_response)
124124

125125
def test_dbx_rm(self):
126126
bot_response = "DELETED File/Folder : [foo](https://www.dropbox.com/home/foo)"
127-
with patch('dropbox.dropbox.Dropbox.files_delete', side_effect=create_file), \
127+
with patch('dropbox.Dropbox.files_delete', side_effect=create_file), \
128128
self.mock_config_info(self.config_info):
129129
self.verify_reply('rm foo', bot_response)
130130

131131
def test_dbx_rm_error(self):
132132
bot_response = "Please provide a correct folder path and name.\n"\
133133
"Usage: `rm <foldername>` to delete a folder in root directory."
134-
with patch('dropbox.dropbox.Dropbox.files_delete', side_effect=Exception()), \
134+
with patch('dropbox.Dropbox.files_delete', side_effect=Exception()), \
135135
self.mock_config_info(self.config_info):
136136
self.verify_reply('rm foo', bot_response)
137137

138138
def test_dbx_write(self):
139139
bot_response = "Written to file: [foo](https://www.dropbox.com/home/foo)"
140-
with patch('dropbox.dropbox.Dropbox.files_upload', side_effect=create_file), \
140+
with patch('dropbox.Dropbox.files_upload', side_effect=create_file), \
141141
self.mock_config_info(self.config_info):
142142
self.verify_reply('write foo boo', bot_response)
143143

144144
def test_dbx_write_error(self):
145145
bot_response = "Incorrect file path or file already exists.\n"\
146146
"Usage: `write <filename> CONTENT`"
147-
with patch('dropbox.dropbox.Dropbox.files_upload', side_effect=Exception()), \
147+
with patch('dropbox.Dropbox.files_upload', side_effect=Exception()), \
148148
self.mock_config_info(self.config_info):
149149
self.verify_reply('write foo boo', bot_response)
150150

151151
def test_dbx_read(self):
152152
bot_response = "**foo** :\nboo"
153-
with patch('dropbox.dropbox.Dropbox.files_download', side_effect=download_file), \
153+
with patch('dropbox.Dropbox.files_download', side_effect=download_file), \
154154
self.mock_config_info(self.config_info):
155155
self.verify_reply('read foo', bot_response)
156156

157157
def test_dbx_read_error(self):
158158
bot_response = "Please provide a correct file path\n"\
159159
"Usage: `read <filename>` to read content of a file"
160-
with patch('dropbox.dropbox.Dropbox.files_download', side_effect=Exception()), \
160+
with patch('dropbox.Dropbox.files_download', side_effect=Exception()), \
161161
self.mock_config_info(self.config_info):
162162
self.verify_reply('read foo', bot_response)
163163

164164
def test_dbx_search(self):
165165
bot_response = " - [foo](https://www.dropbox.com/home/foo)\n"\
166166
" - [fooboo](https://www.dropbox.com/home/fooboo)"
167-
with patch('dropbox.dropbox.Dropbox.files_search', side_effect=search_files), \
167+
with patch('dropbox.Dropbox.files_search', side_effect=search_files), \
168168
self.mock_config_info(self.config_info):
169169
self.verify_reply('search foo', bot_response)
170170

171171
def test_dbx_search_empty(self):
172172
bot_response = "No files/folders found matching your query.\n"\
173173
"For file name searching, the last token is used for prefix matching"\
174174
" (i.e. “bat c” matches “bat cave” but not “batman car”)."
175-
with patch('dropbox.dropbox.Dropbox.files_search', side_effect=get_empty_search_result), \
175+
with patch('dropbox.Dropbox.files_search', side_effect=get_empty_search_result), \
176176
self.mock_config_info(self.config_info):
177177
self.verify_reply('search boo --fd foo', bot_response)
178178

179179
def test_dbx_search_error(self):
180180
bot_response = "Usage: `search <foldername> query --mr 10 --fd <folderName>`\n"\
181181
"Note:`--mr <int>` is optional and is used to specify maximun results.\n"\
182182
" `--fd <folderName>` to search in specific folder."
183-
with patch('dropbox.dropbox.Dropbox.files_search', side_effect=Exception()), \
183+
with patch('dropbox.Dropbox.files_search', side_effect=Exception()), \
184184
self.mock_config_info(self.config_info):
185185
self.verify_reply('search foo', bot_response)
186186

187187
def test_dbx_share(self):
188188
bot_response = 'http://www.foo.com/boo'
189-
with patch('dropbox.dropbox.Dropbox.sharing_create_shared_link', side_effect=get_shared_link), \
189+
with patch('dropbox.Dropbox.sharing_create_shared_link', side_effect=get_shared_link), \
190190
self.mock_config_info(self.config_info):
191191
self.verify_reply('share boo', bot_response)
192192

193193
def test_dbx_share_error(self):
194194
bot_response = "Please provide a correct file name.\n"\
195195
"Usage: `share <filename>`"
196-
with patch('dropbox.dropbox.Dropbox.sharing_create_shared_link', side_effect=Exception()), \
196+
with patch('dropbox.Dropbox.sharing_create_shared_link', side_effect=Exception()), \
197197
self.mock_config_info(self.config_info):
198198
self.verify_reply('share boo', bot_response)
199199

0 commit comments

Comments
 (0)