From a472447f2e22dc4474104a668f417db6db1733a1 Mon Sep 17 00:00:00 2001 From: Gorbunov Leonid <49250787+Melifarmo@users.noreply.github.com> Date: Thu, 13 Jun 2024 17:10:14 +0300 Subject: [PATCH] feat: Added manager_huid field into UserFromCSV (#474) Co-authored-by: Leonid Gorbunov --- pybotx/client/users_api/user_from_csv.py | 4 +++- pybotx/models/users.py | 2 ++ pyproject.toml | 2 +- tests/client/users_api/test_users_as_csv.py | 16 +++++++++------- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pybotx/client/users_api/user_from_csv.py b/pybotx/client/users_api/user_from_csv.py index bd760c54..3e058dcd 100644 --- a/pybotx/client/users_api/user_from_csv.py +++ b/pybotx/client/users_api/user_from_csv.py @@ -25,8 +25,9 @@ class BotXAPIUserFromCSVResult(VerifiedPayloadBaseModel): company: Optional[str] = Field(alias="Company") department: Optional[str] = Field(alias="Department") position: Optional[str] = Field(alias="Position") + manager_huid: Optional[UUID] = Field(alias="Manager HUID") - @validator("email", "company", "department", "position", pre=True) + @validator("email", "company", "department", "position", "manager_huid", pre=True) @classmethod def replace_empty_string_with_none(cls, field_value: str) -> Optional[str]: if field_value == "": @@ -47,4 +48,5 @@ def to_domain(self) -> UserFromCSV: company=self.company, department=self.department, position=self.position, + manager_huid=self.manager_huid, ) diff --git a/pybotx/models/users.py b/pybotx/models/users.py index f043f505..6301ba85 100644 --- a/pybotx/models/users.py +++ b/pybotx/models/users.py @@ -49,6 +49,7 @@ class UserFromCSV: company: User company. department: User department. position: User position. + manager_huid: User's manager huid. """ huid: UUID @@ -62,3 +63,4 @@ class UserFromCSV: company: Optional[str] = None department: Optional[str] = None position: Optional[str] = None + manager_huid: Optional[UUID] = None diff --git a/pyproject.toml b/pyproject.toml index eda0bab3..015eb704 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pybotx" -version = "0.67.1" +version = "0.68.0" description = "A python library for interacting with eXpress BotX API" authors = [ "Sidnev Nikolay ", diff --git a/tests/client/users_api/test_users_as_csv.py b/tests/client/users_api/test_users_as_csv.py index 9b82085b..9c49ff50 100644 --- a/tests/client/users_api/test_users_as_csv.py +++ b/tests/client/users_api/test_users_as_csv.py @@ -72,9 +72,9 @@ async def test__users_as_csv__succeed( return_value=httpx.Response( status_code=HTTPStatus.OK, content=( - b"HUID,AD Login,Domain,AD E-mail,Name,Sync source,Active,Kind,Company,Department,Position\n" - b"dbc8934f-d0d7-4a9e-89df-d45c137a851c,test_user_17,cts.example.com,,test_user_17,ad,true,cts_user,,,\n" - b"13a6909c-bce1-4dbf-8359-efb7ef8e5b34,test_user_18,cts.example.com,,test_user_18,unsupported,true,cts_user,,," + b"HUID,AD Login,Domain,AD E-mail,Name,Sync source,Active,Kind,Company,Department,Position,Manager HUID\n" + b"dbc8934f-d0d7-4a9e-89df-d45c137a851c,test_user_17,cts.example.com,,test_user_17,ad,false,cts_user,Company,Department,Position,13a6909c-bce1-4dbf-8359-efb7ef8e5b34\n" + b"13a6909c-bce1-4dbf-8359-efb7ef8e5b34,test_user_18,cts.example.com,,test_user_18,unsupported,true,cts_user,,,," ), ), ) @@ -97,12 +97,13 @@ async def test__users_as_csv__succeed( ad_domain="cts.example.com", username="test_user_17", sync_source=SyncSourceTypes.AD, - active=True, + active=False, user_kind=UserKinds.CTS_USER, email=None, - company=None, - department=None, - position=None, + company="Company", + department="Department", + position="Position", + manager_huid=UUID("13a6909c-bce1-4dbf-8359-efb7ef8e5b34"), ), UserFromCSV( huid=UUID("13a6909c-bce1-4dbf-8359-efb7ef8e5b34"), @@ -116,5 +117,6 @@ async def test__users_as_csv__succeed( company=None, department=None, position=None, + manager_huid=None, ), ]