Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fetch_application_emojis route deserialization #2050

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/2050.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `fetch_application_emojis` endpoint deserialization
6 changes: 4 additions & 2 deletions hikari/impl/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2447,8 +2447,10 @@ async def fetch_application_emojis(
) -> typing.Sequence[emojis.KnownCustomEmoji]:
route = routes.GET_APPLICATION_EMOJIS.compile(application=application)
response = await self._request(route)
assert isinstance(response, list)
return [self._entity_factory.deserialize_known_custom_emoji(emoji_payload) for emoji_payload in response]
assert isinstance(response, dict)
return [
self._entity_factory.deserialize_known_custom_emoji(emoji_payload) for emoji_payload in response["items"]
]

async def create_application_emoji(
self, application: snowflakes.SnowflakeishOr[guilds.PartialApplication], name: str, image: files.Resourceish
Expand Down
2 changes: 1 addition & 1 deletion tests/hikari/impl/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3966,7 +3966,7 @@ async def test_fetch_application_emojis(self, rest_client):
emoji1 = StubModel(456)
emoji2 = StubModel(789)
expected_route = routes.GET_APPLICATION_EMOJIS.compile(application=123)
rest_client._request = mock.AsyncMock(return_value=[{"id": "456"}, {"id": "789"}])
rest_client._request = mock.AsyncMock(return_value={"items": [{"id": "456"}, {"id": "789"}]})
rest_client._entity_factory.deserialize_known_custom_emoji = mock.Mock(side_effect=[emoji1, emoji2])

assert await rest_client.fetch_application_emojis(StubModel(123)) == [emoji1, emoji2]
Expand Down