Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
it-bott-integrasjoner
ubw-client
Commits
aba1372f
Commit
aba1372f
authored
Jan 27, 2021
by
Andreas Ellewsen
Browse files
Simplify alias handling and fix test
parent
561a6b1a
Pipeline
#51722
passed with stage
in 1 minute and 33 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/fixtures/bruker.json
View file @
aba1372f
...
...
@@ -20,7 +20,7 @@
"passwordUpdated"
:
"2019-03-14T18:50:10.827"
,
"unit4Id"
:
""
},
"roleAndCompan
y
"
:
[
"role
s
AndCompan
ies
"
:
[
{
"roleId"
:
"D-ANMODER"
,
"companyId"
:
"72"
,
...
...
ubw_client/client.py
View file @
aba1372f
...
...
@@ -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
]:
...
...
ubw_client/models.py
View file @
aba1372f
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment