def test_requires_usergroup_self(self):
"""
Test requires usergroup decorator with self as first argument.
"""
with patch("ownbot.auth.User") as user_mock,\
patch("test_auth.Update") as update_mock:
user_mock = user_mock.return_value
user_mock.has_acces.return_value = True
@ownbot.auth.requires_usergroup("foo")
def my_command_handler(self, bot, update):
"""Dummy command handler"""
print(self, bot, update)
return True
bot_mock = Mock(spec=Bot)
update_mock = Update(1337)
called = my_command_handler(None, bot_mock, update_mock)
self.assertTrue(called)
评论列表
文章目录