예제 #1
0
    def test_rmuser_no_args(self):
        """
            Test rmuser command if the wrong number of args is passed
        """
        bot = Mock(spec=Bot)
        update = self.__get_dummy_update()

        AdminCommands._AdminCommands__rm_user(  # pylint: disable=no-member, protected-access
            bot, update, [])

        bot.sendMessage.assert_called_with(chat_id=1,
                                           text="Usage: rmuser <user> <group>")
예제 #2
0
    def test_rmuser_no_args(self):
        """
            Test rmuser command if the wrong number of args is passed
        """
        bot = Mock(spec=Bot)
        update = self.__get_dummy_update()

        AdminCommands._AdminCommands__rm_user(  # pylint: disable=no-member, protected-access
            bot, update, [])

        bot.sendMessage.assert_called_with(chat_id=1,
                                           text="Usage: rmuser <user> <group>")
예제 #3
0
    def test_rmuser(self):
        """
            Test rmuser command
        """
        bot = Mock(spec=Bot)
        update = self.__get_dummy_update()

        with patch("ownbot.admincommands.UserManager") as usrmgr_mock:
            usrmgr_mock.return_value.rm_user.return_value = True
            AdminCommands._AdminCommands__rm_user(  # pylint: disable=no-member, protected-access
                bot, update, ["@foouser", "foogroup"])
            bot.sendMessage.assert_called_with(
                chat_id=1,
                text="Removed user '@foouser' from the group 'foogroup'.")
예제 #4
0
    def test_rmuser(self):
        """
            Test rmuser command
        """
        bot = Mock(spec=Bot)
        update = self.__get_dummy_update()

        with patch("ownbot.admincommands.UserManager") as usrmgr_mock:
            usrmgr_mock.return_value.rm_user.return_value = True
            AdminCommands._AdminCommands__rm_user(  # pylint: disable=no-member, protected-access
                bot, update, ["@foouser", "foogroup"])
            bot.sendMessage.assert_called_with(
                chat_id=1,
                text="Removed user '@foouser' from the group 'foogroup'.")
예제 #5
0
    def test_rmuser_usr_not_in_grp(self):
        """
            Test rmuser command if user is not in group
        """
        bot = Mock(spec=Bot)
        update = self.__get_dummy_update()

        with patch("ownbot.admincommands.UserManager") as usrmgr_mock:
            usrmgr_mock.return_value.rm_user.return_value = False
            AdminCommands._AdminCommands__rm_user(  # pylint: disable=no-member, protected-access
                bot, update, ["@foouser", "foogroup"])
            bot.sendMessage.assert_called_with(
                chat_id=1,
                text="The user '@foouser' could not"\
                " be found in the group 'foogroup'!")
예제 #6
0
    def test_rmuser_usr_not_in_grp(self):
        """
            Test rmuser command if user is not in group
        """
        bot = Mock(spec=Bot)
        update = self.__get_dummy_update()

        with patch("ownbot.admincommands.UserManager") as usrmgr_mock:
            usrmgr_mock.return_value.rm_user.return_value = False
            AdminCommands._AdminCommands__rm_user(  # pylint: disable=no-member, protected-access
                bot, update, ["@foouser", "foogroup"])
            bot.sendMessage.assert_called_with(
                chat_id=1,
                text="The user '@foouser' could not"\
                " be found in the group 'foogroup'!")