Skip to content

Commit

Permalink
feat: Added 10 fields into UserFromCSV (#475)
Browse files Browse the repository at this point in the history
Co-authored-by: Leonid Gorbunov <[email protected]>
  • Loading branch information
Melifarmo and Leonid Gorbunov authored Jun 18, 2024
1 parent a472447 commit 848971a
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 5 deletions.
39 changes: 38 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,36 @@ class BotXAPIUserFromCSVResult(VerifiedPayloadBaseModel):
company: Optional[str] = Field(alias="Company")
department: Optional[str] = Field(alias="Department")
position: Optional[str] = Field(alias="Position")
avatar: Optional[str] = Field(alias="Avatar")
avatar_preview: Optional[str] = Field(alias="Avatar preview")
office: Optional[str] = Field(alias="Office")
manager: Optional[str] = Field(alias="Manager")
manager_huid: Optional[UUID] = Field(alias="Manager HUID")
description: Optional[str] = Field(alias="Description")
phone: Optional[str] = Field(alias="Phone")
other_phone: Optional[str] = Field(alias="Other phone")
ip_phone: Optional[str] = Field(alias="IP phone")
other_ip_phone: Optional[str] = Field(alias="Other IP phone")
personnel_number: Optional[str] = Field(alias="Personnel number")

@validator("email", "company", "department", "position", "manager_huid", pre=True)
@validator(
"email",
"company",
"department",
"position",
"avatar",
"avatar_preview",
"office",
"manager",
"manager_huid",
"description",
"phone",
"other_phone",
"ip_phone",
"other_ip_phone",
"personnel_number",
pre=True,
)
@classmethod
def replace_empty_string_with_none(cls, field_value: str) -> Optional[str]:
if field_value == "":
Expand All @@ -48,5 +75,15 @@ def to_domain(self) -> UserFromCSV:
company=self.company,
department=self.department,
position=self.position,
avatar=self.avatar,
avatar_preview=self.avatar_preview,
office=self.office,
manager=self.manager,
manager_huid=self.manager_huid,
description=self.description,
phone=self.phone,
other_phone=self.other_phone,
ip_phone=self.ip_phone,
other_ip_phone=self.other_ip_phone,
personnel_number=self.personnel_number,
)
20 changes: 20 additions & 0 deletions pybotx/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,17 @@ class UserFromCSV:
company: User company.
department: User department.
position: User position.
avatar: Src to full avatar.
avatar_preview: Src to avatar.
office: Office info.
manager: User's manager full name.
manager_huid: User's manager huid.
description: Description.
phone: Phone number.
other_phone: Extra phone number.
ip_phone: Ip phone info.
other_ip_phone: Extra ip phone.
personnel_number: User's tabel number.
"""

huid: UUID
Expand All @@ -63,4 +73,14 @@ class UserFromCSV:
company: Optional[str] = None
department: Optional[str] = None
position: Optional[str] = None
avatar: Optional[str] = None
avatar_preview: Optional[str] = None
office: Optional[str] = None
manager: Optional[str] = None
manager_huid: Optional[UUID] = None
description: Optional[str] = None
phone: Optional[str] = None
other_phone: Optional[str] = None
ip_phone: Optional[str] = None
other_ip_phone: Optional[str] = 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 <[email protected]>",
Expand Down
26 changes: 23 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,Description,IP phone,Other IP phone,Phone,Other phone,Avatar,Office,Avatar preview\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,Description,Ip_phone,Other_ip_phone,Phone,Other_phone,Avatar,Office,Avatar_preview\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,7 +103,17 @@ 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"),
description="Description",
ip_phone="Ip_phone",
other_ip_phone="Other_ip_phone",
phone="Phone",
other_phone="Other_phone",
avatar="Avatar",
office="Office",
avatar_preview="Avatar_preview",
),
UserFromCSV(
huid=UUID("13a6909c-bce1-4dbf-8359-efb7ef8e5b34"),
Expand All @@ -117,6 +127,16 @@ async def test__users_as_csv__succeed(
company=None,
department=None,
position=None,
manager=None,
manager_huid=None,
personnel_number=None,
description=None,
ip_phone=None,
other_ip_phone=None,
phone=None,
other_phone=None,
avatar=None,
office=None,
avatar_preview=None,
),
]

0 comments on commit 848971a

Please sign in to comment.