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

This commit is contained in:
neiljp (Neil Pilgrim) 2018-05-27 22:38:39 -07:00 committed by showell
parent b51b6d0361
commit 8e1d4f524b
2 changed files with 18 additions and 18 deletions

View file

@ -110,7 +110,7 @@ class BaremetricsHandler(object):
account_data = account_response.json() account_data = account_response.json()
account_data = account_data['account'] account_data = account_data['account']
template = ['**Your account information:** ', template = ['**Your account information:**',
'Id: {id}', 'Id: {id}',
'Company: {company}', 'Company: {company}',
'Default Currency: {currency}'] 'Default Currency: {currency}']
@ -144,15 +144,15 @@ class BaremetricsHandler(object):
'Active: {active}', 'Active: {active}',
'Interval: {interval}', 'Interval: {interval}',
'Interval Count: {interval_count}', 'Interval Count: {interval_count}',
'Amounts: ']) 'Amounts:'])
response = ['**Listing plans:** '] response = ['**Listing plans:**']
for index, plan in enumerate(plans_data): for index, plan in enumerate(plans_data):
response += ([template.format(_count=index + 1, **plan)] + response += ([template.format(_count=index + 1, **plan)] +
[' - {amount} {currency}'.format(**amount) [' - {amount} {currency}'.format(**amount)
for amount in plan['amounts']] + for amount in plan['amounts']] +
['']) [''])
return '\n'.join(response + ['']) return '\n'.join(response)
def get_customers(self, source_id: str) -> str: def get_customers(self, source_id: str) -> str:
url = 'https://api.baremetrics.com/v1/{}/customers'.format(source_id) url = 'https://api.baremetrics.com/v1/{}/customers'.format(source_id)
@ -168,15 +168,15 @@ class BaremetricsHandler(object):
'Active: {is_active}', 'Active: {is_active}',
'Email: {email}', 'Email: {email}',
'Notes: {notes}', 'Notes: {notes}',
'Current Plans: ']) 'Current Plans:'])
response = ['**Listing customers:** '] response = ['**Listing customers:**']
for index, customer in enumerate(customers_data): for index, customer in enumerate(customers_data):
response += ([template.format(_count=index + 1, **customer)] + response += ([template.format(_count=index + 1, **customer)] +
[' - {name}'.format(**plan) [' - {name}'.format(**plan)
for plan in customer['current_plans']] + for plan in customer['current_plans']] +
['']) [''])
return '\n'.join(response + ['']) return '\n'.join(response)
def get_subscriptions(self, source_id: str) -> str: def get_subscriptions(self, source_id: str) -> str:
url = 'https://api.baremetrics.com/v1/{}/subscriptions'.format(source_id) url = 'https://api.baremetrics.com/v1/{}/subscriptions'.format(source_id)
@ -191,8 +191,8 @@ class BaremetricsHandler(object):
'Customer Email: {email}', 'Customer Email: {email}',
'Active: {_active}', 'Active: {_active}',
'Plan Name: {_plan_name}', 'Plan Name: {_plan_name}',
'Plan Amounts:' ]) 'Plan Amounts:'])
response = ['**Listing subscriptions:** '] response = ['**Listing subscriptions:**']
for index, subscription in enumerate(subscriptions_data): for index, subscription in enumerate(subscriptions_data):
response += ([template.format(_count=index + 1, response += ([template.format(_count=index + 1,
_active=subscription['active'], _active=subscription['active'],
@ -202,7 +202,7 @@ class BaremetricsHandler(object):
for amount in subscription['plan']['amounts']] + for amount in subscription['plan']['amounts']] +
['']) [''])
return '\n'.join(response + ['']) return '\n'.join(response)
def create_plan(self, parameters: List[str]) -> str: def create_plan(self, parameters: List[str]) -> str:
data_header = { data_header = {

View file

@ -39,7 +39,7 @@ class TestBaremetricsBot(BotTestCase):
def test_account_info_command(self) -> None: def test_account_info_command(self) -> None:
with self.mock_config_info({'api_key': 'TEST'}): with self.mock_config_info({'api_key': 'TEST'}):
with self.mock_http_conversation('account_info'): 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') 'Currency: United States Dollar')
def test_list_sources_command(self) -> None: def test_list_sources_command(self) -> None:
@ -49,26 +49,26 @@ class TestBaremetricsBot(BotTestCase):
'baremetrics\nProvider ID: None\n\n') 'baremetrics\nProvider ID: None\n\n')
def test_list_plans_command(self) -> None: def test_list_plans_command(self) -> None:
r = '**Listing plans:** \n1.Name: Plan 1\nActive: True\nInterval: year\nInterval Count: 1\nAmounts: \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\n2.Name: Plan 2\nActive: True\nInterval: year\nInterval Count: 1\nAmounts:\n' \
' - 450000 USD\n\n' ' - 450000 USD\n'
with self.mock_config_info({'api_key': 'TEST'}): with self.mock_config_info({'api_key': 'TEST'}):
with self.mock_http_conversation('list_plans'): with self.mock_http_conversation('list_plans'):
self.verify_reply('list-plans TEST', r) self.verify_reply('list-plans TEST', r)
def test_list_customers_command(self) -> None: def test_list_customers_command(self) -> None:
r = '**Listing customers:** \n1.Name: Customer 1\nDisplay Name: Customer 1\nOID: customer_1\nActive: True\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\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_config_info({'api_key': 'TEST'}):
with self.mock_http_conversation('list_customers'): with self.mock_http_conversation('list_customers'):
self.verify_reply('list-customers TEST', r) self.verify_reply('list-customers TEST', r)
def test_list_subscriptions_command(self) -> None: 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' \ '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_config_info({'api_key': 'TEST'}):
with self.mock_http_conversation('list_subscriptions'): with self.mock_http_conversation('list_subscriptions'):