youtube bot: Replace sys.exit() with bot_handler.quit().

This commit is contained in:
Robert Hönig 2017-12-30 21:45:20 +01:00 committed by showell
parent ff65666ac8
commit 9bf64c0c21
2 changed files with 3 additions and 4 deletions

View file

@ -39,7 +39,7 @@ class TestYoutubeBot(BotTestCase):
with self.mock_config_info({'key': 'somethinginvalid', 'number_of_results': '5', 'video_region': 'US'}), \ with self.mock_config_info({'key': 'somethinginvalid', 'number_of_results': '5', 'video_region': 'US'}), \
self.mock_http_conversation('test_invalid_key'), \ self.mock_http_conversation('test_invalid_key'), \
self.assertRaises(SystemExit) as se: # type: ignore self.assertRaises(bot_handler.BotQuitException):
bot.initialize(bot_handler) bot.initialize(bot_handler)
def test_multiple(self) -> None: def test_multiple(self) -> None:

View file

@ -31,9 +31,8 @@ class YoutubeHandler(object):
search_youtube('test', self.config_info['key'], self.config_info['video_region']) search_youtube('test', self.config_info['key'], self.config_info['video_region'])
except HTTPError as e: except HTTPError as e:
if (e.response.json()['error']['errors'][0]['reason'] == 'keyInvalid'): if (e.response.json()['error']['errors'][0]['reason'] == 'keyInvalid'):
logging.error('Invalid key.' bot_handler.quit('Invalid key.'
'Follow the instructions in doc.md for setting API key.') 'Follow the instructions in doc.md for setting API key.')
sys.exit(1)
else: else:
raise raise
except ConnectionError: except ConnectionError: