diff --git a/tests/test_core/test_webhook_alert.py b/tests/test_core/test_webhook_alert.py index cc515319..e82684eb 100644 --- a/tests/test_core/test_webhook_alert.py +++ b/tests/test_core/test_webhook_alert.py @@ -25,18 +25,18 @@ def test_noop_when_unset(app): def test_posts_when_configured(app): with app.app_context(): with patch('shopdb.utils.mailer.get_webhook_config', return_value=CFG), \ - patch('shopdb.utils.mailer.requests') as req: - req.post.return_value.status_code = 200 + patch('shopdb.utils.mailer.requests') as mock_requests: + mock_requests.post.return_value.status_code = 200 ok, err = send_webhook('Low stock', 'x down') assert ok is True and err is None - assert req.post.call_args[0][0] == CFG['url'] - assert req.post.call_args[1]['json']['@type'] == 'MessageCard' + assert mock_requests.post.call_args[0][0] == CFG['url'] + assert mock_requests.post.call_args[1]['json']['@type'] == 'MessageCard' def test_send_alert_fans_out_to_webhook(app): with app.app_context(): with patch('shopdb.utils.mailer.get_webhook_config', return_value=CFG), \ - patch('shopdb.utils.mailer.requests') as req: - req.post.return_value.status_code = 200 + patch('shopdb.utils.mailer.requests') as mock_requests: + mock_requests.post.return_value.status_code = 200 send_alert('Subject', '
Body
') - assert req.post.called # webhook fired even with no email recipients + assert mock_requests.post.called # webhook fired even with no email recipients