From 8e1d4f524bdc7bbe4475c2c3e4424729e201d9a2 Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Sun, 27 May 2018 22:38:39 -0700 Subject: [PATCH] baremetrics: Remove extra newlines & spaces in code and tests. --- .../bots/baremetrics/baremetrics.py | 20 +++++++++---------- .../bots/baremetrics/test_baremetrics.py | 16 +++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/baremetrics/baremetrics.py b/zulip_bots/zulip_bots/bots/baremetrics/baremetrics.py index b9af587..780471d 100644 --- a/zulip_bots/zulip_bots/bots/baremetrics/baremetrics.py +++ b/zulip_bots/zulip_bots/bots/baremetrics/baremetrics.py @@ -110,7 +110,7 @@ class BaremetricsHandler(object): account_data = account_response.json() account_data = account_data['account'] - template = ['**Your account information:** ', + template = ['**Your account information:**', 'Id: {id}', 'Company: {company}', 'Default Currency: {currency}'] @@ -144,15 +144,15 @@ class BaremetricsHandler(object): 'Active: {active}', 'Interval: {interval}', 'Interval Count: {interval_count}', - 'Amounts: ']) - response = ['**Listing plans:** '] + 'Amounts:']) + response = ['**Listing plans:**'] for index, plan in enumerate(plans_data): response += ([template.format(_count=index + 1, **plan)] + [' - {amount} {currency}'.format(**amount) for amount in plan['amounts']] + ['']) - return '\n'.join(response + ['']) + return '\n'.join(response) def get_customers(self, source_id: str) -> str: url = 'https://api.baremetrics.com/v1/{}/customers'.format(source_id) @@ -168,15 +168,15 @@ class BaremetricsHandler(object): 'Active: {is_active}', 'Email: {email}', 'Notes: {notes}', - 'Current Plans: ']) - response = ['**Listing customers:** '] + 'Current Plans:']) + response = ['**Listing customers:**'] for index, customer in enumerate(customers_data): response += ([template.format(_count=index + 1, **customer)] + [' - {name}'.format(**plan) for plan in customer['current_plans']] + ['']) - return '\n'.join(response + ['']) + return '\n'.join(response) def get_subscriptions(self, source_id: str) -> str: url = 'https://api.baremetrics.com/v1/{}/subscriptions'.format(source_id) @@ -191,8 +191,8 @@ class BaremetricsHandler(object): 'Customer Email: {email}', 'Active: {_active}', 'Plan Name: {_plan_name}', - 'Plan Amounts:' ]) - response = ['**Listing subscriptions:** '] + 'Plan Amounts:']) + response = ['**Listing subscriptions:**'] for index, subscription in enumerate(subscriptions_data): response += ([template.format(_count=index + 1, _active=subscription['active'], @@ -202,7 +202,7 @@ class BaremetricsHandler(object): for amount in subscription['plan']['amounts']] + ['']) - return '\n'.join(response + ['']) + return '\n'.join(response) def create_plan(self, parameters: List[str]) -> str: data_header = { diff --git a/zulip_bots/zulip_bots/bots/baremetrics/test_baremetrics.py b/zulip_bots/zulip_bots/bots/baremetrics/test_baremetrics.py index ed46f72..4037bb7 100644 --- a/zulip_bots/zulip_bots/bots/baremetrics/test_baremetrics.py +++ b/zulip_bots/zulip_bots/bots/baremetrics/test_baremetrics.py @@ -39,7 +39,7 @@ class TestBaremetricsBot(BotTestCase): def test_account_info_command(self) -> None: with self.mock_config_info({'api_key': 'TEST'}): with self.mock_http_conversation('account_info'): - self.verify_reply('account-info', '**Your account information:** \nId: 376418\nCompany: NA\nDefault ' + self.verify_reply('account-info', '**Your account information:**\nId: 376418\nCompany: NA\nDefault ' 'Currency: United States Dollar') def test_list_sources_command(self) -> None: @@ -49,26 +49,26 @@ class TestBaremetricsBot(BotTestCase): 'baremetrics\nProvider ID: None\n\n') def test_list_plans_command(self) -> None: - r = '**Listing plans:** \n1.Name: Plan 1\nActive: True\nInterval: year\nInterval Count: 1\nAmounts: \n' \ - ' - 450000 USD\n\n2.Name: Plan 2\nActive: True\nInterval: year\nInterval Count: 1\nAmounts: \n' \ - ' - 450000 USD\n\n' + r = '**Listing plans:**\n1.Name: Plan 1\nActive: True\nInterval: year\nInterval Count: 1\nAmounts:\n' \ + ' - 450000 USD\n\n2.Name: Plan 2\nActive: True\nInterval: year\nInterval Count: 1\nAmounts:\n' \ + ' - 450000 USD\n' with self.mock_config_info({'api_key': 'TEST'}): with self.mock_http_conversation('list_plans'): self.verify_reply('list-plans TEST', r) def test_list_customers_command(self) -> None: - r = '**Listing customers:** \n1.Name: Customer 1\nDisplay Name: Customer 1\nOID: customer_1\nActive: True\n' \ - 'Email: customer_1@baremetrics.com\nNotes: Here are some notes\nCurrent Plans: \n - Plan 1\n\n' + r = '**Listing customers:**\n1.Name: Customer 1\nDisplay Name: Customer 1\nOID: customer_1\nActive: True\n' \ + 'Email: customer_1@baremetrics.com\nNotes: Here are some notes\nCurrent Plans:\n - Plan 1\n' with self.mock_config_info({'api_key': 'TEST'}): with self.mock_http_conversation('list_customers'): self.verify_reply('list-customers TEST', r) def test_list_subscriptions_command(self) -> None: - r = '**Listing subscriptions:** \n1.Customer Name: Customer 1\nCustomer Display Name: Customer 1\n' \ + r = '**Listing subscriptions:**\n1.Customer Name: Customer 1\nCustomer Display Name: Customer 1\n' \ 'Customer OID: customer_1\nCustomer Email: customer_1@baremetrics.com\nActive: True\n' \ - 'Plan Name: Plan 1\nPlan Amounts: \n - 1000 $\n\n' + 'Plan Name: Plan 1\nPlan Amounts:\n - 1000 $\n' with self.mock_config_info({'api_key': 'TEST'}): with self.mock_http_conversation('list_subscriptions'):