Skip to content

Commit

Permalink
Merge branch 'chore/update-dependencies' into dependabot/pip/autoflak…
Browse files Browse the repository at this point in the history
…e-1.7.8
  • Loading branch information
kutuzov13 committed Nov 8, 2023
2 parents 297b853 + 9a244b3 commit 655c727
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 17 deletions.
20 changes: 10 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pybotx/client/chats_api/chat_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BotXAPIChatInfoMember(VerifiedPayloadBaseModel):

class BotXAPIChatInfoResult(VerifiedPayloadBaseModel):
chat_type: APIChatTypes
creator: UUID
creator: Optional[UUID]
description: Optional[str] = None
group_chat_id: UUID
inserted_at: dt
Expand Down
4 changes: 2 additions & 2 deletions pybotx/client/smartapps_api/smartapp_custom_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
class BotXAPISmartAppCustomNotificationNestedPayload(UnverifiedPayloadBaseModel):
title: str
body: str
meta: Missing[Dict[str, Any]]


class BotXAPISmartAppCustomNotificationRequestPayload(UnverifiedPayloadBaseModel):
group_chat_id: UUID
payload: BotXAPISmartAppCustomNotificationNestedPayload
meta: Missing[Dict[str, Any]]

@classmethod
def from_domain(
Expand All @@ -29,8 +29,8 @@ def from_domain(
payload=BotXAPISmartAppCustomNotificationNestedPayload(
title=title,
body=body,
meta=meta,
),
meta=meta,
)


Expand Down
2 changes: 1 addition & 1 deletion pybotx/models/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ChatInfo:
"""

chat_type: ChatTypes
creator_id: UUID
creator_id: Optional[UUID]
description: Optional[str]
chat_id: UUID
created_at: dt
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybotx"
version = "0.60.0"
version = "0.60.2"
description = "A python library for interacting with eXpress BotX API"
authors = [
"Sidnev Nikolay <nsidnev@ccsteam.ru>",
Expand All @@ -16,7 +16,7 @@ repository = "https://github.com/ExpressApp/pybotx"
[tool.poetry.dependencies]
python = ">=3.8,<3.12"

aiofiles = ">=0.7.0,<0.9.0"
aiofiles = ">=0.7.0,<23.3.0"
httpx = "0.23.0"
loguru = ">=0.6.0,<0.7.0"
mypy-extensions = ">=0.2.0,<0.5.0"
Expand Down
80 changes: 80 additions & 0 deletions tests/client/chats_api/test_chat_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,83 @@ async def test__chat_info__skipped_members(
)
assert "One or more unsupported user types skipped" in loguru_caplog.text
assert endpoint.called


async def test__open_channel_info__succeed(
respx_mock: MockRouter,
host: str,
bot_id: UUID,
datetime_formatter: Callable[[str], dt],
bot_account: BotAccountWithSecret,
) -> None:
# - Arrange -
endpoint = respx_mock.get(
f"https://{host}/api/v3/botx/chats/info",
headers={"Authorization": "Bearer token"},
params={"group_chat_id": "e53d5080-68f7-5050-bb4f-005efd375612"},
).mock(
return_value=httpx.Response(
HTTPStatus.OK,
json={
"status": "ok",
"result": {
"chat_type": "channel",
"creator": None,
"description": None,
"group_chat_id": "e53d5080-68f7-5050-bb4f-005efd375612",
"inserted_at": "2023-10-26T07:49:53.821672Z",
"members": [
{
"admin": True,
"server_id": "a619fcfa-a19b-5256-a592-9b0e75ca0896",
"user_huid": "6fafda2c-6505-57a5-a088-25ea5d1d0364",
"user_kind": "cts_user",
},
{
"admin": False,
"user_huid": "705df263-6bfd-536a-9d51-13524afaab5c",
"server_id": "a619fcfa-a19b-5256-a592-9b0e75ca0896",
"user_kind": "botx",
},
],
"name": "Open Channel Example",
"shared_history": False,
"updated_at": "2023-10-26T08:09:30.721566Z",
},
},
),
)

built_bot = Bot(collectors=[HandlerCollector()], bot_accounts=[bot_account])

# - Act -
async with lifespan_wrapper(built_bot) as bot:
chat_info = await bot.chat_info(
bot_id=bot_id,
chat_id=UUID("e53d5080-68f7-5050-bb4f-005efd375612"),
)

# - Assert -
assert chat_info == ChatInfo(
chat_type=ChatTypes.CHANNEL,
creator_id=None,
description=None,
chat_id=UUID("e53d5080-68f7-5050-bb4f-005efd375612"),
created_at=datetime_formatter("2023-10-26T07:49:53.821672Z"),
members=[
ChatInfoMember(
is_admin=True,
huid=UUID("6fafda2c-6505-57a5-a088-25ea5d1d0364"),
kind=UserKinds.CTS_USER,
),
ChatInfoMember(
is_admin=False,
huid=UUID("705df263-6bfd-536a-9d51-13524afaab5c"),
kind=UserKinds.BOT,
),
],
name="Open Channel Example",
shared_history=False,
)

assert endpoint.called
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ async def test__send_smartapp_custom_notification__succeed(
"payload": {
"title": "test",
"body": "test",
"meta": {"message": "ping"},
},
"meta": {"message": "ping"},
},
).mock(
return_value=httpx.Response(
Expand Down

0 comments on commit 655c727

Please sign in to comment.