idonethis: Remove extra newlines in code & tests.
Also rename list_steams -> list_teams.
This commit is contained in:
parent
9b782e8357
commit
ce4404b9db
|
@ -64,8 +64,8 @@ def api_list_entries(team_id: Optional[str]=None) -> List[Dict[str, Any]]:
|
||||||
def api_create_entry(body: str, team_id: str) -> Dict[str, Any]:
|
def api_create_entry(body: str, team_id: str) -> Dict[str, Any]:
|
||||||
return make_API_request("/entries", "POST", {"body": body, "team_id": team_id})
|
return make_API_request("/entries", "POST", {"body": body, "team_id": team_id})
|
||||||
|
|
||||||
def list_steams() -> str:
|
def list_teams() -> str:
|
||||||
response = ["Teams:"] + [" * " + team['name'] for team in api_list_team()] + [""]
|
response = ["Teams:"] + [" * " + team['name'] for team in api_list_team()]
|
||||||
return "\n".join(response)
|
return "\n".join(response)
|
||||||
|
|
||||||
def get_team_hash(team_name: str) -> str:
|
def get_team_hash(team_name: str) -> str:
|
||||||
|
@ -78,26 +78,27 @@ def team_info(team_name: str) -> str:
|
||||||
data = api_show_team(get_team_hash(team_name))
|
data = api_show_team(get_team_hash(team_name))
|
||||||
return "\n".join(["Team Name: {name}",
|
return "\n".join(["Team Name: {name}",
|
||||||
"ID: `{hash_id}`",
|
"ID: `{hash_id}`",
|
||||||
"Created at: {created_at}", ""]).format(**data)
|
"Created at: {created_at}"]).format(**data)
|
||||||
|
|
||||||
def entries_list(team_name: str) -> str:
|
def entries_list(team_name: str) -> str:
|
||||||
if team_name:
|
if team_name:
|
||||||
data = api_list_entries(get_team_hash(team_name))
|
data = api_list_entries(get_team_hash(team_name))
|
||||||
response = "Entries for {}:\n".format(team_name)
|
response = "Entries for {}:".format(team_name)
|
||||||
else:
|
else:
|
||||||
data = api_list_entries()
|
data = api_list_entries()
|
||||||
response = "Entries for all teams:\n"
|
response = "Entries for all teams:"
|
||||||
for entry in data:
|
for entry in data:
|
||||||
response += "\n".join(
|
response += "\n".join(
|
||||||
[" * {body_formatted}",
|
["",
|
||||||
|
" * {body_formatted}",
|
||||||
" * Created at: {created_at}",
|
" * Created at: {created_at}",
|
||||||
" * Status: {status}",
|
" * Status: {status}",
|
||||||
" * User: {username}",
|
" * User: {username}",
|
||||||
" * Team: {teamname}",
|
" * Team: {teamname}",
|
||||||
" * ID: {hash_id}",
|
" * ID: {hash_id}"
|
||||||
""]).format(username=entry['user']['full_name'],
|
]).format(username=entry['user']['full_name'],
|
||||||
teamname=entry['team']['name'],
|
teamname=entry['team']['name'],
|
||||||
**entry)
|
**entry)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def create_entry(message: str) -> str:
|
def create_entry(message: str) -> str:
|
||||||
|
@ -188,7 +189,7 @@ Below are some of the commands you can use, and what they do.
|
||||||
try:
|
try:
|
||||||
command = " ".join(message_content[:2])
|
command = " ".join(message_content[:2])
|
||||||
if command in ["teams list", "list teams"]:
|
if command in ["teams list", "list teams"]:
|
||||||
reply = list_steams()
|
reply = list_teams()
|
||||||
elif command in ["teams info", "team info"]:
|
elif command in ["teams info", "team info"]:
|
||||||
if len(message_content) > 2:
|
if len(message_content) > 2:
|
||||||
reply = team_info(" ".join(message_content[2:]))
|
reply = team_info(" ".join(message_content[2:]))
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestIDoneThisBot(BotTestCase):
|
||||||
with self.mock_config_info({'api_key': '12345678', 'default_team': 'testing team 1'}), \
|
with self.mock_config_info({'api_key': '12345678', 'default_team': 'testing team 1'}), \
|
||||||
self.mock_http_conversation('team_list'):
|
self.mock_http_conversation('team_list'):
|
||||||
self.verify_reply('list teams',
|
self.verify_reply('list teams',
|
||||||
'Teams:\n * testing team 1\n * test_team_2\n')
|
'Teams:\n * testing team 1\n * test_team_2')
|
||||||
|
|
||||||
def test_show_team_no_team(self) -> None:
|
def test_show_team_no_team(self) -> None:
|
||||||
with self.mock_config_info({'api_key': '12345678', 'default_team': 'testing team 1'}), \
|
with self.mock_config_info({'api_key': '12345678', 'default_team': 'testing team 1'}), \
|
||||||
|
@ -57,7 +57,7 @@ class TestIDoneThisBot(BotTestCase):
|
||||||
self.verify_reply('team info testing team 1',
|
self.verify_reply('team info testing team 1',
|
||||||
'Team Name: testing team 1\n'
|
'Team Name: testing team 1\n'
|
||||||
'ID: `31415926535`\n'
|
'ID: `31415926535`\n'
|
||||||
'Created at: 2017-12-28T19:12:55.121+11:00\n')
|
'Created at: 2017-12-28T19:12:55.121+11:00')
|
||||||
get_team_hashFunction.assert_called_with('testing team 1')
|
get_team_hashFunction.assert_called_with('testing team 1')
|
||||||
|
|
||||||
def test_entries_list(self) -> None:
|
def test_entries_list(self) -> None:
|
||||||
|
@ -83,7 +83,7 @@ class TestIDoneThisBot(BotTestCase):
|
||||||
' * Status: done\n'
|
' * Status: done\n'
|
||||||
' * User: John Doe\n'
|
' * User: John Doe\n'
|
||||||
' * Team: testing team 1\n'
|
' * Team: testing team 1\n'
|
||||||
' * ID: 72c8241d2218464433268c5abd6625ac104e3d8f\n')
|
' * ID: 72c8241d2218464433268c5abd6625ac104e3d8f')
|
||||||
|
|
||||||
def test_bot_responds_to_empty_message(self) -> None:
|
def test_bot_responds_to_empty_message(self) -> None:
|
||||||
with self.mock_config_info({'api_key': '12345678', 'bot_info': 'team'}), \
|
with self.mock_config_info({'api_key': '12345678', 'bot_info': 'team'}), \
|
||||||
|
|
Loading…
Reference in a new issue