cleanup: Remove more unused variables.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
54b2578204
commit
a01e5e37f4
|
@ -226,7 +226,6 @@ class TestDropboxBot(BotTestCase, DefaultTests):
|
||||||
mkdir_error_response = "ERROR: syntax: mkdir <path>"
|
mkdir_error_response = "ERROR: syntax: mkdir <path>"
|
||||||
rm_error_response = "ERROR: syntax: rm <path>"
|
rm_error_response = "ERROR: syntax: rm <path>"
|
||||||
write_error_response = "ERROR: syntax: write <path> <some_text>"
|
write_error_response = "ERROR: syntax: write <path> <some_text>"
|
||||||
search_error_response = "ERROR: syntax: search <path> <some_text> <max_results>"
|
|
||||||
share_error_response = "ERROR: syntax: share <path>"
|
share_error_response = "ERROR: syntax: share <path>"
|
||||||
usage_error_response = "ERROR: syntax: usage"
|
usage_error_response = "ERROR: syntax: usage"
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class TestFileUploaderBot(BotTestCase, DefaultTests):
|
||||||
def test_file_upload_failed(self, is_file: Mock, resolve: Mock) -> None:
|
def test_file_upload_failed(self, is_file: Mock, resolve: Mock) -> None:
|
||||||
server_reply = dict(result='', msg='error')
|
server_reply = dict(result='', msg='error')
|
||||||
with patch('zulip_bots.test_lib.StubBotHandler.upload_file_from_path',
|
with patch('zulip_bots.test_lib.StubBotHandler.upload_file_from_path',
|
||||||
return_value=server_reply) as m:
|
return_value=server_reply):
|
||||||
self.verify_reply('file.txt', 'Failed to upload `/file.txt` file: error')
|
self.verify_reply('file.txt', 'Failed to upload `/file.txt` file: error')
|
||||||
|
|
||||||
@patch('pathlib.Path.resolve', return_value=Path('/file.txt'))
|
@patch('pathlib.Path.resolve', return_value=Path('/file.txt'))
|
||||||
|
@ -27,7 +27,7 @@ class TestFileUploaderBot(BotTestCase, DefaultTests):
|
||||||
def test_file_upload_success(self, is_file: Mock, resolve: Mock) -> None:
|
def test_file_upload_success(self, is_file: Mock, resolve: Mock) -> None:
|
||||||
server_reply = dict(result='success', uri='https://file/uri')
|
server_reply = dict(result='success', uri='https://file/uri')
|
||||||
with patch('zulip_bots.test_lib.StubBotHandler.upload_file_from_path',
|
with patch('zulip_bots.test_lib.StubBotHandler.upload_file_from_path',
|
||||||
return_value=server_reply) as m:
|
return_value=server_reply):
|
||||||
self.verify_reply('file.txt', '[file.txt](https://file/uri)')
|
self.verify_reply('file.txt', '[file.txt](https://file/uri)')
|
||||||
|
|
||||||
def test_help(self):
|
def test_help(self):
|
||||||
|
|
|
@ -69,7 +69,7 @@ def get_url_gif_giphy(keyword: str, api_key: str) -> Union[int, str]:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = requests.get(url, params=query)
|
data = requests.get(url, params=query)
|
||||||
except requests.exceptions.ConnectionError as e: # Usually triggered by bad connection.
|
except requests.exceptions.ConnectionError: # Usually triggered by bad connection.
|
||||||
logging.exception('Bad connection')
|
logging.exception('Bad connection')
|
||||||
raise
|
raise
|
||||||
data.raise_for_status()
|
data.raise_for_status()
|
||||||
|
|
|
@ -61,7 +61,7 @@ class TestIDoneThisBot(BotTestCase, DefaultTests):
|
||||||
def test_entries_list(self) -> None:
|
def test_entries_list(self) -> None:
|
||||||
with self.mock_config_info({'api_key': '12345678', 'default_team': 'testing team 1'}), \
|
with self.mock_config_info({'api_key': '12345678', 'default_team': 'testing team 1'}), \
|
||||||
self.mock_http_conversation('test_entries_list'), \
|
self.mock_http_conversation('test_entries_list'), \
|
||||||
patch('zulip_bots.bots.idonethis.idonethis.get_team_hash', return_value='31415926535') as get_team_hashFunction:
|
patch('zulip_bots.bots.idonethis.idonethis.get_team_hash', return_value='31415926535'):
|
||||||
self.verify_reply('entries list testing team 1',
|
self.verify_reply('entries list testing team 1',
|
||||||
'Entries for testing team 1:\n'
|
'Entries for testing team 1:\n'
|
||||||
' * TESTING\n'
|
' * TESTING\n'
|
||||||
|
|
|
@ -100,7 +100,7 @@ class TestTriviaQuizBot(BotTestCase, DefaultTests):
|
||||||
# test correct answer
|
# test correct answer
|
||||||
with patch('zulip_bots.bots.trivia_quiz.trivia_quiz.get_quiz_from_id',
|
with patch('zulip_bots.bots.trivia_quiz.trivia_quiz.get_quiz_from_id',
|
||||||
return_value=json.dumps(quiz)):
|
return_value=json.dumps(quiz)):
|
||||||
with patch('zulip_bots.bots.trivia_quiz.trivia_quiz.start_new_quiz') as mock_new_quiz:
|
with patch('zulip_bots.bots.trivia_quiz.trivia_quiz.start_new_quiz'):
|
||||||
self._test('answer Q001 A', ':tada: **Amphibian** is correct, Foo Test User!')
|
self._test('answer Q001 A', ':tada: **Amphibian** is correct, Foo Test User!')
|
||||||
|
|
||||||
def test_update_quiz(self) -> None:
|
def test_update_quiz(self) -> None:
|
||||||
|
|
|
@ -113,7 +113,7 @@ def fetch_xkcd_query(mode: int, comic_id: Optional[str]=None) -> Dict[str, str]:
|
||||||
raise XkcdServerError()
|
raise XkcdServerError()
|
||||||
|
|
||||||
xkcd_json = fetched.json()
|
xkcd_json = fetched.json()
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError:
|
||||||
logging.exception("Connection Error")
|
logging.exception("Connection Error")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ def search_youtube(query: str, key: str,
|
||||||
url = 'https://www.googleapis.com/youtube/v3/search'
|
url = 'https://www.googleapis.com/youtube/v3/search'
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, params=params)
|
r = requests.get(url, params=params)
|
||||||
except ConnectionError as e: # Usually triggered by bad connection.
|
except ConnectionError: # Usually triggered by bad connection.
|
||||||
logging.exception('Bad connection')
|
logging.exception('Bad connection')
|
||||||
raise
|
raise
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
|
|
@ -133,13 +133,12 @@ class LibTest(TestCase):
|
||||||
def test_content_and_full_content(self):
|
def test_content_and_full_content(self):
|
||||||
client = FakeClient()
|
client = FakeClient()
|
||||||
client.get_profile()
|
client.get_profile()
|
||||||
handler = ExternalBotHandler(
|
ExternalBotHandler(
|
||||||
client=client,
|
client=client,
|
||||||
root_dir=None,
|
root_dir=None,
|
||||||
bot_details=None,
|
bot_details=None,
|
||||||
bot_config_file=None
|
bot_config_file=None
|
||||||
)
|
)
|
||||||
to = {'email': 'Some@User'}
|
|
||||||
|
|
||||||
def test_run_message_handler_for_bot(self):
|
def test_run_message_handler_for_bot(self):
|
||||||
with patch('zulip_bots.lib.Client', new=FakeClient) as fake_client:
|
with patch('zulip_bots.lib.Client', new=FakeClient) as fake_client:
|
||||||
|
|
Loading…
Reference in a new issue