コード例 #1
0
 def test_create_with_all_params(self):
     x = Footer("Justice League", icon_url="url-1", proxy_icon_url="url-2")
     self.assertEqual(x.text, "Justice League")
     self.assertEqual(x.icon_url, "url-1")
     self.assertEqual(x.proxy_icon_url, "url-2")
     self.assertDictEqual(
         x.asdict(),
         {"text": "Justice League", "icon_url": "url-1", "proxy_icon_url": "url-2"},
     )
コード例 #2
0
 def test_from_dict_full(self):
     embed = Embed(
         title="Justice League",
         description="They said the age of heroes would never come again.",
         url="url-1",
         timestamp=self.now,
         color=0x5CDBF0,
         footer=Footer("TOP SECRET", "url-2", "url-11"),
         image=Image("url-3", "url-4", height=200, width=150),
         thumbnail=Thumbnail("url-5", "url-6", height=100, width=80),
         author=Author("Bruce Wayne", "url-8", "url-9"),
         fields=[Field("fruit", "orange", False), Field("vegetable", "onion", True)],
     )
     embed_dict = embed.asdict()
     embed_2 = Embed.from_dict(embed_dict)
     self.assertEqual(embed, embed_2)
コード例 #3
0
 def test_objects_are_not_equal(self):
     self.assertNotEqual(self.x1, self.y1)
     self.assertNotEqual(self.x1, self.y2)
     self.assertNotEqual(self.x1, self.z)
     self.assertNotEqual(self.x1, Footer("Bruce", "url-1"))
コード例 #4
0
    def test_create_with_full_params(self):
        obj = Embed(
            title="Justice League",
            description="They said the age of heroes would never come again.",
            url="url-1",
            timestamp=self.now,
            color=0x5CDBF0,
            footer=Footer("TOP SECRET", "url-2", "url-11"),
            image=Image("url-3", "url-4", height=200, width=150),
            thumbnail=Thumbnail("url-5", "url-6", height=100, width=80),
            author=Author("Bruce Wayne", "url-8", "url-9"),
            fields=[Field("fruit", "orange", False), Field("vegetable", "onion", True)],
        )
        self.assertEqual(obj.title, "Justice League")
        self.assertEqual(
            obj.description, "They said the age of heroes would never come again."
        )
        self.assertEqual(obj.type, "rich")
        self.assertEqual(obj.url, "url-1")
        self.assertEqual(obj.timestamp, self.now)
        self.assertEqual(obj.color, 0x5CDBF0)
        self.assertEqual(obj.footer, Footer("TOP SECRET", "url-2", "url-11"))
        self.assertEqual(obj.image, Image("url-3", "url-4", height=200, width=150))
        self.assertEqual(
            obj.thumbnail, Thumbnail("url-5", "url-6", height=100, width=80)
        )
        self.assertEqual(obj.author, Author("Bruce Wayne", "url-8", "url-9"))
        self.assertEqual(
            obj.fields,
            [Field("fruit", "orange", False), Field("vegetable", "onion", True)],
        )

        self.maxDiff = None
        self.assertDictEqual(
            obj.asdict(),
            {
                "title": "Justice League",
                "type": "rich",
                "description": "They said the age of heroes would never come again.",
                "url": "url-1",
                "timestamp": self.now,
                "color": 0x5CDBF0,
                "image": {
                    "url": "url-3",
                    "proxy_url": "url-4",
                    "height": 200,
                    "width": 150,
                },
                "thumbnail": {
                    "url": "url-5",
                    "proxy_url": "url-6",
                    "height": 100,
                    "width": 80,
                },
                "footer": {
                    "text": "TOP SECRET",
                    "icon_url": "url-2",
                    "proxy_icon_url": "url-11",
                },
                "author": {"name": "Bruce Wayne", "url": "url-8", "icon_url": "url-9"},
                "fields": [
                    {"name": "fruit", "value": "orange", "inline": False},
                    {"name": "vegetable", "value": "onion", "inline": True},
                ],
            },
        )
コード例 #5
0
 def test_create_with_name_only(self):
     x = Footer("Justice League")
     self.assertEqual(x.text, "Justice League")
     self.assertDictEqual(x.asdict(), {"text": "Justice League"})
コード例 #6
0
 def test_detects_wrong_type_inline(self):
     with self.assertRaises(TypeError):
         Footer("Justice League", inline=int(1))
コード例 #7
0
 def test_detect_missing_params_on_create(self):
     with self.assertRaises(ValueError):
         Footer(None)