コード例 #1
0
ファイル: test_bot.py プロジェクト: EvaisaGiac/twitch-bot
    def test__is_allowed_to_run_command(self):
        bot = Bot()

        bot._get_user_level = Mock(return_value="user")
        assert bot._is_allowed_to_run_command("#a", "a", "addquote") is False
        assert bot._is_allowed_to_run_command("#a", "a", "delquote") is False
        assert bot._is_allowed_to_run_command("#a", "a", "quote") is False
        assert bot._is_allowed_to_run_command("#a", "a", "reg") is False
        assert bot._is_allowed_to_run_command("#a", "a", "def") is False

        bot._get_user_level = Mock(return_value="reg")
        assert bot._is_allowed_to_run_command("#a", "a", "addquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "delquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "quote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "reg") is False
        assert bot._is_allowed_to_run_command("#a", "a", "def") is False

        bot._get_user_level = Mock(return_value="mod")
        assert bot._is_allowed_to_run_command("#a", "a", "addquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "delquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "quote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "reg") is True
        assert bot._is_allowed_to_run_command("#a", "a", "def") is True

        bot._get_user_level = Mock(return_value="owner")
        assert bot._is_allowed_to_run_command("#a", "a", "addquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "delquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "quote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "reg") is True
        assert bot._is_allowed_to_run_command("#a", "a", "def") is True
コード例 #2
0
    def test__is_allowed_to_run_command(self):
        bot = Bot()

        bot._get_user_level = Mock(return_value="user")
        assert bot._is_allowed_to_run_command("#a", "a", "addquote") is False
        assert bot._is_allowed_to_run_command("#a", "a", "delquote") is False
        assert bot._is_allowed_to_run_command("#a", "a", "quote") is False
        assert bot._is_allowed_to_run_command("#a", "a", "reg") is False
        assert bot._is_allowed_to_run_command("#a", "a", "def") is False

        bot._get_user_level = Mock(return_value="reg")
        assert bot._is_allowed_to_run_command("#a", "a", "addquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "delquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "quote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "reg") is False
        assert bot._is_allowed_to_run_command("#a", "a", "def") is False

        bot._get_user_level = Mock(return_value="mod")
        assert bot._is_allowed_to_run_command("#a", "a", "addquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "delquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "quote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "reg") is True
        assert bot._is_allowed_to_run_command("#a", "a", "def") is True

        bot._get_user_level = Mock(return_value="owner")
        assert bot._is_allowed_to_run_command("#a", "a", "addquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "delquote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "quote") is True
        assert bot._is_allowed_to_run_command("#a", "a", "reg") is True
        assert bot._is_allowed_to_run_command("#a", "a", "def") is True