Ejemplo n.º 1
0
    def test_edge_dict_to_embed(self):
        """Tests edge cases for dict_to_embed"""
        data = {
            "author": {
                "icon_url": "$USERAVATAR",
                "name": "test"
            },
            "footer": {
                "icon_url": "$USERAVATAR"
            },
            "timestamp": True,
        }

        mock_message = MockedMessage().to_mock()

        test_embed = dict_to_embed(data, mock_message, {
            "warn_count": 1,
            "kick_count": 2
        })

        user_footer = substitute_args("$USERAVATAR", mock_message, {
            "warn_count": 1,
            "kick_count": 2
        })

        embed = discord.Embed(timestamp=mock_message.created_at)
        embed.set_footer(icon_url=user_footer)
        embed.set_author(
            name="test",
            icon_url=user_footer,
        )

        assert embed.to_dict() == test_embed.to_dict()
Ejemplo n.º 2
0
    def test_further_edge_cases_for_to_dict(self):
        data = {
            "author": {
                "icon_url": "y",
                "name": "test"
            },
            "footer": {
                "icon_url": "x"
            },
            "timestamp": True,
        }

        mock_message = MockedMessage().to_mock()

        test_embed = dict_to_embed(data, mock_message, {
            "warn_count": 1,
            "kick_count": 2
        })

        embed = discord.Embed(timestamp=mock_message.created_at)
        embed.set_footer(icon_url="x")
        embed.set_author(
            name="test",
            icon_url="y",
        )

        assert embed.to_dict() == test_embed.to_dict()
Ejemplo n.º 3
0
    def test_to_dict_colors(self):
        data = {"colour": 0xFFFFFF, "color": 0x000000}
        mock_message = MockedMessage().to_mock()
        data_embed = dict_to_embed(data, mock_message, {
            "warn_count": 1,
            "kick_count": 2
        })
        embed = discord.Embed(color=0xFFFFFF)

        assert embed.to_dict() == data_embed.to_dict()
Ejemplo n.º 4
0
    def test_dict_to_embed(self):
        warn_embed_dict = {
            "title":
            "**Dear Dave**",
            "description":
            "You are being warned for spam, please stop!",
            "color":
            0xFF0000,
            "footer": {
                "text": "BOT"
            },
            "author": {
                "name": "Guild"
            },
            "fields": [
                {
                    "name": "Current warns:",
                    "value": "1"
                },
                {
                    "name": "Current kicks:",
                    "value": "2",
                    "inline": False
                },
            ],
        }

        mock_message = MockedMessage().to_mock()

        test_embed = dict_to_embed(warn_embed_dict, mock_message, {
            "warn_count": 1,
            "kick_count": 2
        })

        embed = discord.Embed(
            title="**Dear Dave**",
            description="You are being warned for spam, please stop!",
            color=0xFF0000,
        )
        embed.set_footer(text="BOT")
        embed.set_author(name="Guild")
        embed.add_field(name="Current warns:", value="1")
        embed.add_field(name="Current kicks:", value="2", inline=False)

        assert embed.to_dict() == test_embed.to_dict()