Commit 113fd80b authored by Petr Kalashnikov's avatar Petr Kalashnikov
Browse files

Merge remote-tracking branch 'origin/master' into botting27

parents 0c5a503e 7f77ef6f
Pipeline #51850 passed with stage
in 1 minute and 37 seconds
......@@ -20,7 +20,7 @@
"passwordUpdated": "2019-03-14T18:50:10.827",
"unit4Id": ""
},
"roleAndCompany": [
"rolesAndCompanies": [
{
"roleId": "D-ANMODER",
"companyId": "72",
......
......@@ -472,6 +472,7 @@ def test_get_bilagstype(client, requests_mock, bilagstype_data):
expected = Bilagstype.from_dict(bilagstype_data[0])
assert expected == received
def test_get_ressurs(client, base_url, requests_mock, ressurs_data):
company_id = "72"
ressurs_id = "99999"
......
......@@ -98,6 +98,7 @@ def test_bilagstype(bilagstype_data):
assert model.updated_at == bilagstype_data[0]["updatedAt"]
assert model.updated_by == bilagstype_data[0]["updatedBy"]
def test_ressurs(ressurs_data):
model = Ressurs(**ressurs_data[0])
assert model.age == ressurs_data[0]["age"]
......
......@@ -158,6 +158,7 @@ def test_bilagstyper_url_no_override_wo_trailing_slash(config_no_overrides):
url = client.urls.get_bilagstype("72", "TT")
assert url == "https://example.com/base/bilagstyper/v1/72/TT"
def test_ressurser_url_no_override_w_trailing_slash(config_no_overrides):
config_no_overrides["rest"]["base_url"] += "base/" # trailing slash
client = get_client(**config_no_overrides)
......
......@@ -545,30 +545,38 @@ 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
def get_partial_arbeidsordrer(self, company_id: str) -> typing.List[models.PartialArbeidsordre]:
# 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]:
url = self.urls.get_arbeidsordre(company_id)
headers = self.config.rest.endpoints.begreper.headers
r = self.get(url,
headers=headers,
params={
'select': ','.join(
['companyId',
'workOrderId',
'dateFrom',
'dateTo',
'periodFrom',
'periodTo',
'status',
'projectId',
'workOrderName',
'costCentre',
'projectManagerId',
'category1',
'lastUpdated(updatedAt,updatedBy)'])})
r = self.get(
url,
headers=headers,
params={
"select": ",".join(
[
"companyId",
"workOrderId",
"dateFrom",
"dateTo",
"periodFrom",
"periodTo",
"status",
"projectId",
"workOrderName",
"costCentre",
"projectManagerId",
"category1",
"lastUpdated(updatedAt,updatedBy)",
]
)
},
)
return [models.PartialArbeidsordre.from_dict(x) for x in r]
def get_perioder(
self,
company_id: str,
......
......@@ -155,6 +155,7 @@ class Transaction(BaseModel):
voucher_no: int
voucher_type: str
ex_ref: typing.Optional[str]
ext_inv_ref: typing.Optional[str]
ext_arch_ref_col: typing.Optional[str]
class Config:
......@@ -606,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
......@@ -625,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