def test_assign_first_to_with_self(self):
"""
Test assign first to decorator with self as first argument.
"""
with patch("ownbot.auth.User") as user_mock,\
patch("test_auth.Update") as update_mock,\
patch("ownbot.auth.UserManager") as usrmgr_mock:
user_mock = user_mock.return_value
usrmgr_mock.return_value.group_is_empty.return_value = True
@ownbot.auth.assign_first_to("foo")
def my_command_handler(self, bot, update):
"""Dummy command handler"""
print(self, bot, update)
bot_mock = Mock(spec=Bot)
update_mock = Update(1337)
my_command_handler(None, bot_mock, update_mock)
self.assertTrue(usrmgr_mock.return_value.group_is_empty.called)
self.assertTrue(user_mock.save.called)
评论列表
文章目录