def setUp(self):
        TestAnnouncementBase.setUp(self)

        self.mock_role = create_mock_role(12345, "MyRole")

        self.member_thumbs_up1 = create_mock_user()
        self.member_thumbs_up2 = create_mock_user()
        self.member_shrug_1 = create_mock_user()
        self.member_shrug_2 = create_mock_user()

        mock_reaction_1 = create_mock_reaction(
            "👍", members=[self.member_thumbs_up1, self.member_thumbs_up2])
        mock_reaction_2 = create_mock_reaction(
            "🤷", members=[self.member_shrug_1, self.member_shrug_2])

        self.mock_message_to_edit = create_mock_message(
            "the message",
            "the chan",
            reactions=[mock_reaction_1, mock_reaction_2])

        add_reaction_mock = MagicMock(return_value=Future())
        add_reaction_mock.return_value.set_result(None)
        type(self.mock_message_to_edit).add_reaction = add_reaction_mock

        remove_reaction_mock = MagicMock(return_value=Future())
        remove_reaction_mock.return_value.set_result(None)
        type(self.mock_message_to_edit).remove_reaction = remove_reaction_mock

        self.mock_discord_service.get_matching_message = MagicMock(
            return_value=Future())
        self.mock_discord_service.get_matching_message.return_value.set_result(
            self.mock_message_to_edit)
    async def runTest(self):
        mock_role = create_mock_role(12345, "MyRole")
        mock_message = create_mock_message(
            "!announce create operations This is an operation announcement",
            "the chan",
            user_roles=[mock_role])
        await self.announcement_service.bot_command_callback(mock_message)

        self.mock_discord_service.send_channel_message.assert_called_with(
            "This is an operation announcement", "operations")
    async def runTest(self):
        mock_role = create_mock_role(12345, "MyRole")
        mock_message = create_mock_message(
            "!announce edit operations 12345 fixed announcement",
            "the chan",
            user_roles=[mock_role])
        await self.announcement_service.bot_command_callback(mock_message)

        self.mock_discord_service.get_matching_message.assert_called_with(
            "operations", 12345)
        self.mock_message_to_edit.edit.assert_called_with(
            content="fixed announcement")
    def setUp(self):
        TestAnnouncementBase.setUp(self)

        self.mock_role = create_mock_role(12345, "MyRole")

        self.mock_message_to_edit = create_mock_message("the message",
                                                        "the chan",
                                                        reactions=[])

        add_reaction_mock = MagicMock(return_value=Future())
        add_reaction_mock.return_value.set_result(None)
        type(self.mock_message_to_edit).add_reaction = add_reaction_mock

        self.mock_discord_service.get_matching_message = MagicMock(
            return_value=Future())
        self.mock_discord_service.get_matching_message.return_value.set_result(
            self.mock_message_to_edit)
    def setUp(self):
        TestAnnouncementBase.setUp(self)

        self.mock_role = create_mock_role(978, "MyRole")
Beispiel #6
0
 def get_role_by_id_sideeffect(self, *args, **kwargs):
     if args[0] == 1:
         return create_mock_role(1, "MyRole1")
     elif args[0] == 2:
         return create_mock_role(2, "MyRole2")