Skip to content

Commit 13b549e

Browse files
committed
- lint and test fix
1 parent 6131956 commit 13b549e

8 files changed

Lines changed: 156 additions & 127 deletions

File tree

pybotx/bot/callbacks/callback_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ def setup_callback_timeout_alarm(self, sync_id: UUID, timeout: float) -> None:
134134
def cancel_callback_timeout_alarm(
135135
self,
136136
sync_id: UUID,
137-
) -> None: ...
137+
) -> None: ... # pragma: no cover
138138

139139
@overload
140140
def cancel_callback_timeout_alarm(
141141
self,
142142
sync_id: UUID,
143143
return_remaining_time: Literal[True],
144-
) -> float: ...
144+
) -> float: ... # pragma: no cover
145145

146146
def cancel_callback_timeout_alarm(
147147
self,

pybotx/bot/callbacks/callback_repo_proto.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ class CallbackRepoProto(Protocol):
1616
async def create_botx_method_callback(
1717
self,
1818
sync_id: UUID,
19-
) -> None: ...
19+
) -> None: ... # pragma: no cover
2020

2121
async def set_botx_method_callback_result(
2222
self,
2323
callback: BotXMethodCallback,
24-
) -> None: ...
24+
) -> None: ... # pragma: no cover
2525

2626
async def wait_botx_method_callback(
2727
self,
2828
sync_id: UUID,
2929
timeout: float,
30-
) -> BotXMethodCallback: ...
30+
) -> BotXMethodCallback: ... # pragma: no cover
3131

3232
async def pop_botx_method_callback(
3333
self,
3434
sync_id: UUID,
35-
) -> "Future[BotXMethodCallback]": ...
35+
) -> "Future[BotXMethodCallback]": ... # pragma: no cover
3636

37-
async def stop_callbacks_waiting(self) -> None: ...
37+
async def stop_callbacks_waiting(self) -> None: ... # pragma: no cover

pybotx/bot/handler_collector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ def decorator(
200200
def default_message_handler(
201201
self,
202202
handler_func: IncomingMessageHandlerFunc,
203-
) -> IncomingMessageHandlerFunc: ...
203+
) -> IncomingMessageHandlerFunc: ... # pragma: no cover
204204

205205
@overload
206206
def default_message_handler(
207207
self,
208208
*,
209209
middlewares: Optional[Sequence[Middleware]] = None,
210-
) -> MessageHandlerDecorator: ...
210+
) -> MessageHandlerDecorator: ... # pragma: no cover
211211

212212
def default_message_handler(
213213
self,

tests/client/users_api/conftest.py

Lines changed: 6 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,6 @@
1-
from typing import Any, Dict
2-
from uuid import UUID
3-
4-
import pytest
5-
6-
from pybotx import UserFromSearch, UserKinds
7-
from tests.client.users_api.convert_to_datetime import convert_to_datetime
8-
9-
10-
@pytest.fixture()
11-
def user_from_search_with_data_json() -> Dict[str, Any]:
12-
return {
13-
"user_huid": "6fafda2c-6505-57a5-a088-25ea5d1d0364",
14-
"ad_login": "ad_user_login",
15-
"ad_domain": "cts.com",
16-
"name": "Bob",
17-
"company": "Bobs Co",
18-
"company_position": "Director",
19-
"department": "Owners",
20-
"emails": ["ad_user@cts.com"],
21-
"user_kind": "cts_user",
22-
"active": True,
23-
"created_at": "2023-03-26T14:36:08.740618Z",
24-
"cts_id": "e0140f4c-4af2-5a2e-9ad1-5f37fceafbaf",
25-
"description": "Director in Owners dep",
26-
"ip_phone": "1271020",
27-
"manager": "Alice",
28-
"office": "SUN",
29-
"other_ip_phone": "32593",
30-
"other_phone": "1254218",
31-
"public_name": "Bobby",
32-
"rts_id": "f46440a4-d930-58d4-b3f5-8110ab846ee3",
33-
"updated_at": "2023-03-26T14:36:08.740618Z",
34-
}
35-
36-
37-
@pytest.fixture
38-
def user_from_search_with_data() -> UserFromSearch:
39-
return UserFromSearch(
40-
huid=UUID("6fafda2c-6505-57a5-a088-25ea5d1d0364"),
41-
ad_login="ad_user_login",
42-
ad_domain="cts.com",
43-
username="Bob",
44-
company="Bobs Co",
45-
company_position="Director",
46-
department="Owners",
47-
emails=["ad_user@cts.com"],
48-
other_id=None,
49-
user_kind=UserKinds.CTS_USER,
50-
active=True,
51-
created_at=convert_to_datetime("2023-03-26T14:36:08.740618Z"),
52-
cts_id=UUID("e0140f4c-4af2-5a2e-9ad1-5f37fceafbaf"),
53-
description="Director in Owners dep",
54-
ip_phone="1271020",
55-
manager="Alice",
56-
office="SUN",
57-
other_ip_phone="32593",
58-
other_phone="1254218",
59-
public_name="Bobby",
60-
rts_id=UUID("f46440a4-d930-58d4-b3f5-8110ab846ee3"),
61-
updated_at=convert_to_datetime("2023-03-26T14:36:08.740618Z"),
62-
)
63-
64-
65-
@pytest.fixture
66-
def user_from_search_without_data_json() -> Dict[str, Any]:
67-
return {
68-
"user_huid": "6fafda2c-6505-57a5-a088-25ea5d1d0364",
69-
"ad_login": "ad_user_login",
70-
"ad_domain": "cts.com",
71-
"name": "Bob",
72-
"company": "Bobs Co",
73-
"company_position": "Director",
74-
"department": "Owners",
75-
"emails": ["ad_user@cts.com"],
76-
"user_kind": "cts_user",
77-
"active": None,
78-
"created_at": None,
79-
"cts_id": None,
80-
"description": None,
81-
"ip_phone": None,
82-
"manager": None,
83-
"office": None,
84-
"other_ip_phone": None,
85-
"other_phone": None,
86-
"public_name": None,
87-
"rts_id": None,
88-
"updated_at": None,
89-
}
90-
91-
92-
@pytest.fixture
93-
def user_from_search_without_data() -> UserFromSearch:
94-
return UserFromSearch(
95-
huid=UUID("6fafda2c-6505-57a5-a088-25ea5d1d0364"),
96-
ad_login="ad_user_login",
97-
ad_domain="cts.com",
98-
username="Bob",
99-
company="Bobs Co",
100-
company_position="Director",
101-
department="Owners",
102-
emails=["ad_user@cts.com"],
103-
other_id=None,
104-
user_kind=UserKinds.CTS_USER,
105-
active=None,
106-
created_at=None,
107-
cts_id=None,
108-
description=None,
109-
ip_phone=None,
110-
manager=None,
111-
office=None,
112-
other_ip_phone=None,
113-
other_phone=None,
114-
public_name=None,
115-
rts_id=None,
116-
updated_at=None,
117-
)
1+
from tests.fixtures.users_api import ( # noqa: F401
2+
user_from_search_with_data,
3+
user_from_search_with_data_json,
4+
user_from_search_without_data,
5+
user_from_search_without_data_json,
6+
)

tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
from pydantic import BaseModel
4242
from contextlib import asynccontextmanager
4343

44+
from tests.fixtures.users_api import ( # noqa: F401
45+
user_from_search_with_data,
46+
user_from_search_with_data_json,
47+
user_from_search_without_data,
48+
user_from_search_without_data_json,
49+
)
50+
4451

4552
@pytest.fixture(autouse=True)
4653
def enable_logger() -> None:

tests/deprecated/test_search_user_by_email_get.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
pytest.mark.mock_authorization,
2222
pytest.mark.usefixtures("respx_mock"),
2323
]
24-
pytest_plugins = ["tests.client.users_api.conftest"]
2524

2625

2726
@pytest.fixture(autouse=True)

tests/fixtures/users_api.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
from typing import Any, Dict
2+
from uuid import UUID
3+
4+
import pytest
5+
6+
from pybotx import UserFromSearch, UserKinds
7+
from tests.client.users_api.convert_to_datetime import convert_to_datetime
8+
9+
10+
@pytest.fixture()
11+
def user_from_search_with_data_json() -> Dict[str, Any]:
12+
return {
13+
"user_huid": "6fafda2c-6505-57a5-a088-25ea5d1d0364",
14+
"ad_login": "ad_user_login",
15+
"ad_domain": "cts.com",
16+
"name": "Bob",
17+
"company": "Bobs Co",
18+
"company_position": "Director",
19+
"department": "Owners",
20+
"emails": ["ad_user@cts.com"],
21+
"user_kind": "cts_user",
22+
"active": True,
23+
"created_at": "2023-03-26T14:36:08.740618Z",
24+
"cts_id": "e0140f4c-4af2-5a2e-9ad1-5f37fceafbaf",
25+
"description": "Director in Owners dep",
26+
"ip_phone": "1271020",
27+
"manager": "Alice",
28+
"office": "SUN",
29+
"other_ip_phone": "32593",
30+
"other_phone": "1254218",
31+
"public_name": "Bobby",
32+
"rts_id": "f46440a4-d930-58d4-b3f5-8110ab846ee3",
33+
"updated_at": "2023-03-26T14:36:08.740618Z",
34+
}
35+
36+
37+
@pytest.fixture
38+
def user_from_search_with_data() -> UserFromSearch:
39+
return UserFromSearch(
40+
huid=UUID("6fafda2c-6505-57a5-a088-25ea5d1d0364"),
41+
ad_login="ad_user_login",
42+
ad_domain="cts.com",
43+
username="Bob",
44+
company="Bobs Co",
45+
company_position="Director",
46+
department="Owners",
47+
emails=["ad_user@cts.com"],
48+
other_id=None,
49+
user_kind=UserKinds.CTS_USER,
50+
active=True,
51+
created_at=convert_to_datetime("2023-03-26T14:36:08.740618Z"),
52+
cts_id=UUID("e0140f4c-4af2-5a2e-9ad1-5f37fceafbaf"),
53+
description="Director in Owners dep",
54+
ip_phone="1271020",
55+
manager="Alice",
56+
office="SUN",
57+
other_ip_phone="32593",
58+
other_phone="1254218",
59+
public_name="Bobby",
60+
rts_id=UUID("f46440a4-d930-58d4-b3f5-8110ab846ee3"),
61+
updated_at=convert_to_datetime("2023-03-26T14:36:08.740618Z"),
62+
)
63+
64+
65+
@pytest.fixture
66+
def user_from_search_without_data_json() -> Dict[str, Any]:
67+
return {
68+
"user_huid": "6fafda2c-6505-57a5-a088-25ea5d1d0364",
69+
"ad_login": "ad_user_login",
70+
"ad_domain": "cts.com",
71+
"name": "Bob",
72+
"company": "Bobs Co",
73+
"company_position": "Director",
74+
"department": "Owners",
75+
"emails": ["ad_user@cts.com"],
76+
"user_kind": "cts_user",
77+
"active": None,
78+
"created_at": None,
79+
"cts_id": None,
80+
"description": None,
81+
"ip_phone": None,
82+
"manager": None,
83+
"office": None,
84+
"other_ip_phone": None,
85+
"other_phone": None,
86+
"public_name": None,
87+
"rts_id": None,
88+
"updated_at": None,
89+
}
90+
91+
92+
@pytest.fixture
93+
def user_from_search_without_data() -> UserFromSearch:
94+
return UserFromSearch(
95+
huid=UUID("6fafda2c-6505-57a5-a088-25ea5d1d0364"),
96+
ad_login="ad_user_login",
97+
ad_domain="cts.com",
98+
username="Bob",
99+
company="Bobs Co",
100+
company_position="Director",
101+
department="Owners",
102+
emails=["ad_user@cts.com"],
103+
other_id=None,
104+
user_kind=UserKinds.CTS_USER,
105+
active=None,
106+
created_at=None,
107+
cts_id=None,
108+
description=None,
109+
ip_phone=None,
110+
manager=None,
111+
office=None,
112+
other_ip_phone=None,
113+
other_phone=None,
114+
public_name=None,
115+
rts_id=None,
116+
updated_at=None,
117+
)

tests/test_files.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,20 @@ async def smartapp_event_handler(event: SmartAppEvent, bot: Bot) -> None:
343343
# - Assert -
344344
assert smartapp_event
345345
assert smartapp_event.files == [domain_async_file]
346+
347+
348+
async def test__async_file_properties_expose_private_fields() -> None:
349+
image = Image(
350+
type=AttachmentTypes.IMAGE,
351+
filename="pass.png",
352+
size=1502345,
353+
is_async_file=True,
354+
_file_id=UUID("8dada2c8-67a6-4434-9dec-570d244e78ee"),
355+
_file_url="https://link.to/file",
356+
_file_mimetype="image/png",
357+
_file_hash="Jd9r+OKpw5y+FSCg1xNTSUkwEo4nCW1Sn1AkotkOpH0=",
358+
)
359+
360+
assert image.file_url == "https://link.to/file"
361+
assert image.file_mimetype == "image/png"
362+
assert image.file_hash == "Jd9r+OKpw5y+FSCg1xNTSUkwEo4nCW1Sn1AkotkOpH0="

0 commit comments

Comments
 (0)