Skip to content

Commit

Permalink
feat: Added manager, personal_number fields into UserFromCSV
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid Gorbunov committed Jun 17, 2024
1 parent 2643349 commit affa609
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
15 changes: 14 additions & 1 deletion pybotx/client/users_api/user_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,20 @@ class BotXAPIUserFromCSVResult(VerifiedPayloadBaseModel):
company: Optional[str] = Field(alias="Company")
department: Optional[str] = Field(alias="Department")
position: Optional[str] = Field(alias="Position")
manager: Optional[str] = Field(alias="Manager")
manager_huid: Optional[UUID] = Field(alias="Manager HUID")
personnel_number: Optional[str] = Field(alias="Personnel number")

@validator("email", "company", "department", "position", "manager_huid", pre=True)
@validator(
"email",
"company",
"department",
"position",
"manager",
"manager_huid",
"personnel_number",
pre=True,
)
@classmethod
def replace_empty_string_with_none(cls, field_value: str) -> Optional[str]:
if field_value == "":
Expand All @@ -48,5 +59,7 @@ def to_domain(self) -> UserFromCSV:
company=self.company,
department=self.department,
position=self.position,
manager=self.manager,
manager_huid=self.manager_huid,
personnel_number=self.personnel_number,
)
4 changes: 4 additions & 0 deletions pybotx/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class UserFromCSV:
company: User company.
department: User department.
position: User position.
manager: User's manager full name.
manager_huid: User's manager huid.
personnel_number: User's tabel number.
"""

huid: UUID
Expand All @@ -63,4 +65,6 @@ class UserFromCSV:
company: Optional[str] = None
department: Optional[str] = None
position: Optional[str] = None
manager: Optional[str] = None
manager_huid: Optional[UUID] = None
personnel_number: Optional[str] = None
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.68.0"
version = "0.68.1"
description = "A python library for interacting with eXpress BotX API"
authors = [
"Sidnev Nikolay <nsidnev@ccsteam.ru>",
Expand Down
10 changes: 7 additions & 3 deletions tests/client/users_api/test_users_as_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,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,,,,"
b"HUID,AD Login,Domain,AD E-mail,Name,Sync source,Active,Kind,Company,Department,Position,Manager,Manager HUID,Personnel number\n"
b"dbc8934f-d0d7-4a9e-89df-d45c137a851c,test_user_17,cts.example.com,,test_user_17,ad,false,cts_user,Company,Department,Position,Manager John,13a6909c-bce1-4dbf-8359-efb7ef8e5b34,Some number\n"
b"13a6909c-bce1-4dbf-8359-efb7ef8e5b34,test_user_18,cts.example.com,,test_user_18,unsupported,true,cts_user,,,,,,"
),
),
)
Expand Down Expand Up @@ -103,6 +103,8 @@ async def test__users_as_csv__succeed(
company="Company",
department="Department",
position="Position",
personnel_number="Some number",
manager="Manager John",
manager_huid=UUID("13a6909c-bce1-4dbf-8359-efb7ef8e5b34"),
),
UserFromCSV(
Expand All @@ -117,6 +119,8 @@ async def test__users_as_csv__succeed(
company=None,
department=None,
position=None,
manager=None,
manager_huid=None,
personnel_number=None,
),
]

0 comments on commit affa609

Please sign in to comment.