test: UserProfile convertation

This commit is contained in:
grey-cat-1908 2023-06-05 13:00:28 +03:00
parent f1012e9465
commit d546175131
3 changed files with 19 additions and 6 deletions

View file

@ -545,7 +545,7 @@ class PartialUser(APIObjectBase):
self: cls = super().__new__(cls) self: cls = super().__new__(cls)
self.username = data["username"] self.username = data["username"]
self.discriminator = data["discriminator"] self.discriminator = data.get("discriminator")
self.avatar = data.get("avatar") self.avatar = data.get("avatar")
self.id = data["id"] self.id = data["id"]
self.socials = UserLinks.from_dict(data.get("socials", {})) self.socials = UserLinks.from_dict(data.get("socials", {}))

View file

@ -13,14 +13,17 @@ resource_bot_dict = {
resource_server_dict = { resource_server_dict = {
"id": "722424773233213460", "id": "722424773233213460",
"name": "BotiCord.top", "name": "BotiCord.top",
"tags": [ "tags": [134, 132],
134,
132
],
"status": 1, "status": 1,
"createdDate": "2023-05-23T15:16:45.387Z", "createdDate": "2023-05-23T15:16:45.387Z",
"premium": {}, "premium": {},
} }
user_profile_dict = {
"id": "585766846268047370",
"username": "Marakarka",
"bots": [resource_bot_dict],
"shortDescription": None,
}
def test_resource_up_convertation(): def test_resource_up_convertation():
@ -53,9 +56,19 @@ def test_resource_bot_convertation():
assert int(model_from_dict.created_date.timestamp()) == 1684794563 assert int(model_from_dict.created_date.timestamp()) == 1684794563
assert model_from_dict.status.name == "PUBLIC" assert model_from_dict.status.name == "PUBLIC"
def test_resource_server_convertation(): def test_resource_server_convertation():
model_from_dict = types.ResourceServer.from_dict(resource_server_dict) model_from_dict = types.ResourceServer.from_dict(resource_server_dict)
assert int(model_from_dict.created_date.timestamp()) == 1684855005 assert int(model_from_dict.created_date.timestamp()) == 1684855005
assert model_from_dict.name == "BotiCord.top" assert model_from_dict.name == "BotiCord.top"
assert model_from_dict.tags[1].name == "GAMES" assert model_from_dict.tags[1].name == "GAMES"
def test_user_profile_convertation():
model_from_dict = types.UserProfile.from_dict(user_profile_dict)
assert model_from_dict.id == "585766846268047370"
assert model_from_dict.username == "Marakarka"
assert model_from_dict.short_description == None
assert model_from_dict.bots[0].id == "947141336451153931"