Skip to content

Commit

Permalink
feat: Add user_kind field to Users API
Browse files Browse the repository at this point in the history
  • Loading branch information
nidemidovich committed Oct 25, 2022
1 parent 0090c57 commit 305a648
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pybotx/client/users_api/user_from_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pydantic import Field

from pybotx.models.api_base import VerifiedPayloadBaseModel
from pybotx.models.enums import APIUserKinds, convert_user_kind_to_domain
from pybotx.models.users import UserFromSearch


Expand All @@ -17,6 +18,7 @@ class BotXAPISearchUserResult(VerifiedPayloadBaseModel):
department: Optional[str] = None
emails: List[str] = Field(default_factory=list)
other_id: Optional[str] = None
user_kind: APIUserKinds


class BotXAPISearchUserResponsePayload(VerifiedPayloadBaseModel):
Expand All @@ -34,4 +36,5 @@ def to_domain(self) -> UserFromSearch:
department=self.result.department,
emails=self.result.emails,
other_id=self.result.other_id,
user_kind=convert_user_kind_to_domain(self.result.user_kind),
)
4 changes: 4 additions & 0 deletions pybotx/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from typing import List, Optional
from uuid import UUID

from pybotx.models.enums import UserKinds


@dataclass
class UserFromSearch:
Expand All @@ -17,6 +19,7 @@ class UserFromSearch:
department: User department.
emails: User emails.
other_id: User other identificator.
user_kind: User kind.
"""

huid: UUID
Expand All @@ -28,3 +31,4 @@ class UserFromSearch:
department: Optional[str]
emails: List[str]
other_id: Optional[str]
user_kind: UserKinds
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybotx"
version = "0.49.0"
version = "0.50.0"
description = "A python library for interacting with eXpress BotX API"
authors = [
"Sidnev Nikolay <[email protected]>",
Expand Down
3 changes: 3 additions & 0 deletions tests/client/users_api/test_search_user_by_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
UserNotFoundError,
lifespan_wrapper,
)
from pybotx.models.enums import UserKinds

pytestmark = [
pytest.mark.asyncio,
Expand Down Expand Up @@ -84,6 +85,7 @@ async def test__search_user_by_email__succeed(
"company_position": "Director",
"department": "Owners",
"emails": ["[email protected]"],
"user_kind": "cts_user",
},
},
),
Expand All @@ -109,6 +111,7 @@ async def test__search_user_by_email__succeed(
department="Owners",
emails=["[email protected]"],
other_id=None,
user_kind=UserKinds.CTS_USER,
)

assert endpoint.called
3 changes: 3 additions & 0 deletions tests/client/users_api/test_search_user_by_huid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
UserNotFoundError,
lifespan_wrapper,
)
from pybotx.models.enums import UserKinds

pytestmark = [
pytest.mark.asyncio,
Expand Down Expand Up @@ -84,6 +85,7 @@ async def test__search_user_by_huid__succeed(
"company_position": "Director",
"department": "Owners",
"emails": ["[email protected]"],
"user_kind": "cts_user",
},
},
),
Expand All @@ -109,6 +111,7 @@ async def test__search_user_by_huid__succeed(
department="Owners",
emails=["[email protected]"],
other_id=None,
user_kind=UserKinds.CTS_USER,
)

assert endpoint.called
3 changes: 3 additions & 0 deletions tests/client/users_api/test_search_user_by_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
UserNotFoundError,
lifespan_wrapper,
)
from pybotx.models.enums import UserKinds

pytestmark = [
pytest.mark.asyncio,
Expand Down Expand Up @@ -85,6 +86,7 @@ async def test__search_user_by_ad__succeed(
"company_position": "Director",
"department": "Owners",
"emails": ["[email protected]"],
"user_kind": "cts_user",
},
},
),
Expand All @@ -111,6 +113,7 @@ async def test__search_user_by_ad__succeed(
department="Owners",
emails=["[email protected]"],
other_id=None,
user_kind=UserKinds.CTS_USER,
)

assert endpoint.called
3 changes: 3 additions & 0 deletions tests/client/users_api/test_search_user_by_other_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
UserNotFoundError,
lifespan_wrapper,
)
from pybotx.models.enums import UserKinds

pytestmark = [
pytest.mark.asyncio,
Expand Down Expand Up @@ -85,6 +86,7 @@ async def test__search_user_by_other_id__succeed(
"department": "Owners",
"emails": ["[email protected]"],
"other_id": "some_id",
"user_kind": "cts_user",
},
},
),
Expand All @@ -110,6 +112,7 @@ async def test__search_user_by_other_id__succeed(
department="Owners",
emails=["[email protected]"],
other_id="some_id",
user_kind=UserKinds.CTS_USER,
)

assert endpoint.called

0 comments on commit 305a648

Please sign in to comment.