コード例 #1
0
    def test_result_defaults(self):
        s = random_string()
        result = Result(success=True, value=s)
        assert result.success is True
        assert result.value == s
        assert result.error is None

        s2 = random_string()
        error = random_string()
        result2 = Result(success=False, value=s2, error=error)

        assert result2.success is False
        assert result2.error == error
        assert result2.value == s2
コード例 #2
0
ファイル: test_replies.py プロジェクト: Seputaes/seplib-red
 def test_embed_build_message_no_emoji(self):
     message = random_string()
     expected = f"{message}"
     embed_reply = EmbedReply(message=message,
                              color=HexColor.success(),
                              emoji=None)
     assert embed_reply.build_message() == expected
コード例 #3
0
ファイル: test_replies.py プロジェクト: Seputaes/seplib-red
    def test_embed_build_embed_no_emoji(self):
        color = HexColor.rebecca_purple()
        message = random_string()
        embed_reply = EmbedReply(message=message, color=color, emoji=None)

        embed = embed_reply.build()
        assert embed.color == color
        assert embed.description == message
コード例 #4
0
ファイル: test_replies.py プロジェクト: Seputaes/seplib-red
 def test_embed_build_message_emoji(self):
     emoji = "\N{PILE OF POO}"
     message = random_string()
     expected = f"{emoji} {message}"
     embed_reply = EmbedReply(message=message,
                              color=HexColor.success(),
                              emoji=emoji)
     assert embed_reply.build_message() == expected
コード例 #5
0
ファイル: test_replies.py プロジェクト: Seputaes/seplib-red
    def test_embed_build_embed_emoji(self):
        emoji = "\N{PILE OF POO}"
        color = HexColor.rebecca_purple()
        message = random_string()
        expected = f"{emoji} {message}"
        embed_reply = EmbedReply(message=message, color=color, emoji=emoji)

        embed = embed_reply.build()
        assert embed.color == color
        assert embed.description == expected
コード例 #6
0
    async def test_cross_raises_other_exceptions(self, monkeypatch,
                                                 red_context):
        class NewBaseException(BaseException):
            pass

        message = random_string()
        exception = NewBaseException(message)

        monkeypatch.setattr("discord.message.Message.add_reaction",
                            coroutine_exception(exception))

        wrapper = ContextWrapper(red_context)
        try:
            await wrapper.cross()
            assert False, "Cross method swallowed non-HTTP exceptions"
        except BaseException as e:
            assert type(e) is NewBaseException
            assert e.args[0] == message
コード例 #7
0
ファイル: test_replies.py プロジェクト: Seputaes/seplib-red
 def test_embed_sets_message(self):
     message = random_string()
     embed_reply = EmbedReply(message=message, color=HexColor.success())
     assert embed_reply.message == message
コード例 #8
0
def message_predicate():
    from redbot.core.utils.predicates import MessagePredicate

    p = MessagePredicate(predicate=None)
    p.result = random_string()
    return p