trello: Remove extra newlines & spaces in code and tests.

This commit is contained in:
neiljp (Neil Pilgrim) 2018-05-27 22:53:09 -07:00 committed by showell
parent 4f224b5dbc
commit 8f0b9adb70
2 changed files with 15 additions and 15 deletions

View file

@ -48,35 +48,35 @@ class TestTrelloBot(BotTestCase):
def test_get_all_boards_command(self) -> None:
with self.mock_config_info(mock_config), patch('requests.get'):
with self.mock_http_conversation('get_all_boards'):
self.verify_reply('get-all-boards', '**Boards:** \n')
self.verify_reply('get-all-boards', '**Boards:**\n')
with self.mock_http_conversation('get_board_descs'):
bot_instance = TrelloHandler()
bot_instance.initialize(StubBotHandler)
self.assertEqual(bot_instance.get_board_descs(['TEST']), '1.[TEST](TEST) (`TEST`)\n')
self.assertEqual(bot_instance.get_board_descs(['TEST']), '1.[TEST](TEST) (`TEST`)')
def test_get_all_cards_command(self) -> None:
with self.mock_config_info(mock_config), patch('requests.get'):
with self.mock_http_conversation('get_cards'):
self.verify_reply('get-all-cards TEST', '**Cards:** \n1. [TEST](TEST) (`TEST`)\n')
self.verify_reply('get-all-cards TEST', '**Cards:**\n1. [TEST](TEST) (`TEST`)')
def test_get_all_checklists_command(self) -> None:
with self.mock_config_info(mock_config), patch('requests.get'):
with self.mock_http_conversation('get_checklists'):
self.verify_reply('get-all-checklists TEST', '**Checklists:** \n'
self.verify_reply('get-all-checklists TEST', '**Checklists:**\n'
'1. `TEST`:\n'
' * [X] TEST_1\n * [X] TEST_2\n'
' * [-] TEST_3\n * [-] TEST_4\n')
' * [-] TEST_3\n * [-] TEST_4')
def test_get_all_lists_command(self) -> None:
with self.mock_config_info(mock_config), patch('requests.get'):
with self.mock_http_conversation('get_lists'):
self.verify_reply('get-all-lists TEST', ('**Lists:** \n'
self.verify_reply('get-all-lists TEST', ('**Lists:**\n'
'1. TEST_A\n'
' * TEST_1\n'
'2. TEST_B\n'
' * TEST_2\n'))
' * TEST_2'))
def test_command_exceptions(self) -> None:
"""Add appropriate tests here for all additional commands with try/except blocks.

View file

@ -84,7 +84,7 @@ class TrelloHandler(object):
try:
boards = board_ids_response.json()['idBoards']
bot_response = '**Boards:** \n' + self.get_board_descs(boards)
bot_response = '**Boards:**\n' + self.get_board_descs(boards)
except (KeyError, ValueError, TypeError):
return RESPONSE_ERROR_MESSAGE
@ -100,7 +100,7 @@ class TrelloHandler(object):
board_data = board_desc_response.json()
bot_response += ['{_count}.[{name}]({url}) (`{id}`)'.format(_count=index + 1, **board_data)]
return '\n'.join(bot_response + [''])
return '\n'.join(bot_response)
def get_all_cards(self, content: List[str]) -> str:
if len(content) != 2:
@ -112,14 +112,14 @@ class TrelloHandler(object):
try:
cards = cards_response.json()
bot_response = ['**Cards:** ']
bot_response = ['**Cards:**']
for index, card in enumerate(cards):
bot_response += ['{_count}. [{name}]({url}) (`{id}`)'.format(_count=index + 1, **card)]
except (KeyError, ValueError, TypeError):
return RESPONSE_ERROR_MESSAGE
return '\n'.join(bot_response + [''])
return '\n'.join(bot_response)
def get_all_checklists(self, content: List[str]) -> str:
if len(content) != 2:
@ -131,7 +131,7 @@ class TrelloHandler(object):
try:
checklists = checklists_response.json()
bot_response = ['**Checklists:** ']
bot_response = ['**Checklists:**']
for index, checklist in enumerate(checklists):
bot_response += ['{}. `{}`:'.format(index + 1, checklist['name'])]
@ -142,7 +142,7 @@ class TrelloHandler(object):
except (KeyError, ValueError, TypeError):
return RESPONSE_ERROR_MESSAGE
return '\n'.join(bot_response + [''])
return '\n'.join(bot_response)
def get_all_lists(self, content: List[str]) -> str:
if len(content) != 2:
@ -154,7 +154,7 @@ class TrelloHandler(object):
try:
lists = lists_response.json()
bot_response = ['**Lists:** ']
bot_response = ['**Lists:**']
for index, _list in enumerate(lists):
bot_response += ['{}. {}'.format(index + 1, _list['name'])]
@ -166,6 +166,6 @@ class TrelloHandler(object):
except (KeyError, ValueError, TypeError):
return RESPONSE_ERROR_MESSAGE
return '\n'.join(bot_response + [''])
return '\n'.join(bot_response)
handler_class = TrelloHandler