-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_methods.py
58 lines (44 loc) · 2.17 KB
/
test_methods.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import unittest
from typing import Union
from image_processor_client import Client
import asyncio
class DiscordMethodsTest(unittest.TestCase):
SAMPLE_SS_MSG_DATA = {
"name": "The Cosmos",
"message_content": "Python unittests test message content.",
"avatar_url": "https://i.imgur.com/qgATqeF.png",
}
SAMPLE_WELCOME_BANNER_DATA = {
"banner_url": "https://cdn.discordapp.com/attachments/509502631849492525/548458089897000977/Banner.png",
"avatar_url": "https://cdn.discordapp.com/avatars/331793750273687553/dccee12134542a7ffab8e243ea8cce55.webp",
"name": "The Cosmos",
"discriminator": 7109,
"text": "Welcome to the Universe."
}
SAMPLE_PROFILE_RANK_CARD_DATA = {
"name": "□ | The Cosmos", "discriminator": "#6811",
"avatar_url": "http://localhost/haru.jpg", "text_rank": 7, "voice_rank": 2,
"text_xp": 75, "text_target_xp": 100, "text_total_xp": 1291, "text_level": 11,
"voice_xp": 60, "voice_target_xp": 100, "voice_total_xp": 170, "voice_level": 17,
}
@staticmethod
def __run_async(function):
return asyncio.get_event_loop().run_until_complete(function)
def test_get_msg_ss(self):
return self.__run_async(self._get_msg_ss())
async def _get_msg_ss(self):
client = Client("http://0.0.0.0:5000/")
ss_bytes = await client.discord.ss_message(**self.SAMPLE_SS_MSG_DATA)
self.assertIsInstance(ss_bytes, Union[bytes])
def test_get_welcome_banner(self):
return self.__run_async(self._get_welcome_banner())
async def _get_welcome_banner(self):
client = Client("http://0.0.0.0:5000/")
banner_bytes = await client.discord.get_welcome_banner(**self.SAMPLE_WELCOME_BANNER_DATA)
self.assertIsInstance(banner_bytes, Union[bytes])
def test_union_method(self):
return self.__run_async(self._get_profile_rank_card())
async def _get_profile_rank_card(self):
client = Client("http://127.0.0.1:5000")
rank_card_bytes = await client.discord.get_profile_rank_card(**self.SAMPLE_PROFILE_RANK_CARD_DATA)
self.assertIsInstance(rank_card_bytes, Union[bytes])