Skip to content

Commit d717c59

Browse files
committed
Update tests
1 parent d8a2d17 commit d717c59

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

tests/conftest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def action(request):
2222

2323

2424
@pytest.fixture
25-
async def bot(loop):
26-
b = SirBot(loop=loop)
25+
async def bot(loop) -> SirBot:
26+
b = SirBot()
2727
slack = SlackPlugin(
2828
token='token',
2929
verify='supersecuretoken',
@@ -37,8 +37,9 @@ async def bot(loop):
3737

3838
return b
3939

40+
4041
@pytest.fixture
41-
async def slack_bot(bot):
42+
async def slack_bot(bot: SirBot):
4243
slack = SlackPlugin(
4344
token='token',
4445
verify='supersecuretoken',
@@ -47,3 +48,4 @@ async def slack_bot(bot):
4748
)
4849
endpoints.slack.create_endpoints(slack)
4950
bot.load_plugin(slack)
51+
return bot

tests/test_slack_actions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from sirbot import SirBot
33

44

5-
async def test_claim_mentee_response_attachment_is_list(action: dict, test_client, bot: SirBot):
5+
async def test_claim_mentee_response_attachment_is_list(action: dict, aiohttp_client, bot: SirBot):
66
slack_mock = CoroutineMock(return_value={"user": {"profile": {"email": "email@email.com"}}})
77
airtable_mock = CoroutineMock(return_value="U123")
88
bot['plugins']['slack'].api.query = slack_mock
@@ -11,7 +11,6 @@ async def test_claim_mentee_response_attachment_is_list(action: dict, test_clien
1111
bot['plugins']['airtable'].api.get_name_from_record_id = airtable_mock
1212
bot['plugins']['airtable'].api.get_row_from_record_id = airtable_mock
1313

14-
client = await test_client(bot)
14+
client = await aiohttp_client(bot)
1515
await client.post('/slack/actions', data=action)
1616
assert isinstance(slack_mock.call_args[0][1]['attachments'], list)
17-

tests/test_slack_events.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def test_team_join_handler_exists(bot):
1717
)
1818

1919

20-
async def test_team_join_waits_30_seconds(bot, test_client):
20+
async def test_team_join_waits_30_seconds(bot, aiohttp_client):
2121
asyncio.sleep = CoroutineMock()
2222
create_endpoints(bot['plugins']['slack'])
2323
bot['plugins']['slack'] = CoroutineMock()
@@ -26,24 +26,24 @@ async def test_team_join_waits_30_seconds(bot, test_client):
2626
asyncio.sleep.assert_awaited_with(30)
2727

2828

29-
async def test_edits_are_logged(bot, test_client, caplog):
30-
client = await test_client(bot)
29+
async def test_edits_are_logged(bot, aiohttp_client, caplog):
30+
client = await aiohttp_client(bot)
3131

3232
with caplog.at_level(logging.INFO):
3333
await client.post('/slack/events', json=MESSAGE_EDIT)
3434
assert any('CHANGE_LOGGING: edited' in record.message for record in caplog.records)
3535

3636

37-
async def test_deletes_are_logged(bot, test_client, caplog):
38-
client = await test_client(bot)
37+
async def test_deletes_are_logged(bot, aiohttp_client, caplog):
38+
client = await aiohttp_client(bot)
3939

4040
with caplog.at_level(logging.INFO):
4141
await client.post('/slack/events', json=MESSAGE_DELETE)
4242
assert any('CHANGE_LOGGING: deleted' in record.message for record in caplog.records)
4343

4444

45-
async def test_no_other_messages_logged(bot, test_client, caplog):
46-
client = await test_client(bot)
45+
async def test_no_other_messages_logged(bot, aiohttp_client, caplog):
46+
client = await aiohttp_client(bot)
4747

4848
with caplog.at_level(logging.INFO):
4949
await client.post('/slack/events', json=PLAIN_MESSAGE)

0 commit comments

Comments
 (0)