From 8f0b9adb70e2e0a8339444a3b6d4ef6f6f2e21ca Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Sun, 27 May 2018 22:53:09 -0700 Subject: [PATCH] trello: Remove extra newlines & spaces in code and tests. --- zulip_bots/zulip_bots/bots/trello/test_trello.py | 14 +++++++------- zulip_bots/zulip_bots/bots/trello/trello.py | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/trello/test_trello.py b/zulip_bots/zulip_bots/bots/trello/test_trello.py index aa2c884..b54656e 100644 --- a/zulip_bots/zulip_bots/bots/trello/test_trello.py +++ b/zulip_bots/zulip_bots/bots/trello/test_trello.py @@ -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. diff --git a/zulip_bots/zulip_bots/bots/trello/trello.py b/zulip_bots/zulip_bots/bots/trello/trello.py index e889f6c..fd0198a 100644 --- a/zulip_bots/zulip_bots/bots/trello/trello.py +++ b/zulip_bots/zulip_bots/bots/trello/trello.py @@ -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