test_auth.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:ownbot 作者: michaelimfeld 项目源码 文件源码
def test_requires_usergroup_no_acc(self):
        """
            Test requires usergroup decorator if the user has no access
        """
        with patch("ownbot.auth.User") as user_mock:
            user_mock.return_value.has_access.return_value = False

            @ownbot.auth.requires_usergroup("foo")
            def my_command_handler(bot, update):
                """Dummy command handler"""
                print(bot, update)
                return True

            bot_mock = Mock(spec=Bot)
            update = self.__get_dummy_update()
            called = my_command_handler(bot_mock, update)

            self.assertIsNone(called)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号