Commit aba1372f authored by Andreas Ellewsen's avatar Andreas Ellewsen
Browse files

Simplify alias handling and fix test

parent 561a6b1a
Pipeline #51722 passed with stage
in 1 minute and 33 seconds
......@@ -20,7 +20,7 @@
"passwordUpdated": "2019-03-14T18:50:10.827",
"unit4Id": ""
},
"roleAndCompany": [
"rolesAndCompanies": [
{
"roleId": "D-ANMODER",
"companyId": "72",
......
......@@ -545,7 +545,8 @@ class UBWClient:
r = self.get(url, headers=headers)
return [models.Arbeidsordre.from_dict(x) for x in r]
# TODO: Extend get_arbeidsordrer to support the same partial model as the following function
# TODO: Extend get_arbeidsordrer to support the same partial model as the following
# function
def get_partial_arbeidsordrer(
self, company_id: str
) -> typing.List[models.PartialArbeidsordre]:
......
......@@ -607,15 +607,6 @@ class Usage(BaseModel):
allow_population_by_field_name = True
def bruker_model_to_lower_camel(s: str) -> str:
"""Alias generator to avoid breaking PEP8"""
if s == "role_and_company":
return "rolesAndCompanies"
else:
first, *others = s.split("_")
return "".join([first.lower(), *map(str.capitalize, others)])
class Bruker(BaseModel):
user_id: str
user_name: str
......@@ -626,10 +617,12 @@ class Bruker(BaseModel):
language_code: typing.Optional[str]
usage: typing.Optional[Usage]
contact_points: typing.Optional[typing.List[ContactPoint]]
role_and_company: typing.Optional[typing.List[RoleAndCompany]]
role_and_company: typing.Optional[typing.List[RoleAndCompany]] = pydantic.Field(
alias="rolesAndCompanies"
)
class Config:
alias_generator = bruker_model_to_lower_camel
alias_generator = to_lower_camel
allow_population_by_field_name = True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment