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 @@ ...@@ -20,7 +20,7 @@
"passwordUpdated": "2019-03-14T18:50:10.827", "passwordUpdated": "2019-03-14T18:50:10.827",
"unit4Id": "" "unit4Id": ""
}, },
"roleAndCompany": [ "rolesAndCompanies": [
{ {
"roleId": "D-ANMODER", "roleId": "D-ANMODER",
"companyId": "72", "companyId": "72",
......
...@@ -472,6 +472,7 @@ def test_get_bilagstype(client, requests_mock, bilagstype_data): ...@@ -472,6 +472,7 @@ def test_get_bilagstype(client, requests_mock, bilagstype_data):
expected = Bilagstype.from_dict(bilagstype_data[0]) expected = Bilagstype.from_dict(bilagstype_data[0])
assert expected == received assert expected == received
def test_get_ressurs(client, base_url, requests_mock, ressurs_data): def test_get_ressurs(client, base_url, requests_mock, ressurs_data):
company_id = "72" company_id = "72"
ressurs_id = "99999" ressurs_id = "99999"
......
...@@ -98,6 +98,7 @@ def test_bilagstype(bilagstype_data): ...@@ -98,6 +98,7 @@ def test_bilagstype(bilagstype_data):
assert model.updated_at == bilagstype_data[0]["updatedAt"] assert model.updated_at == bilagstype_data[0]["updatedAt"]
assert model.updated_by == bilagstype_data[0]["updatedBy"] assert model.updated_by == bilagstype_data[0]["updatedBy"]
def test_ressurs(ressurs_data): def test_ressurs(ressurs_data):
model = Ressurs(**ressurs_data[0]) model = Ressurs(**ressurs_data[0])
assert model.age == ressurs_data[0]["age"] assert model.age == ressurs_data[0]["age"]
......
...@@ -158,6 +158,7 @@ def test_bilagstyper_url_no_override_wo_trailing_slash(config_no_overrides): ...@@ -158,6 +158,7 @@ def test_bilagstyper_url_no_override_wo_trailing_slash(config_no_overrides):
url = client.urls.get_bilagstype("72", "TT") url = client.urls.get_bilagstype("72", "TT")
assert url == "https://example.com/base/bilagstyper/v1/72/TT" assert url == "https://example.com/base/bilagstyper/v1/72/TT"
def test_ressurser_url_no_override_w_trailing_slash(config_no_overrides): def test_ressurser_url_no_override_w_trailing_slash(config_no_overrides):
config_no_overrides["rest"]["base_url"] += "base/" # trailing slash config_no_overrides["rest"]["base_url"] += "base/" # trailing slash
client = get_client(**config_no_overrides) client = get_client(**config_no_overrides)
......
...@@ -545,30 +545,38 @@ class UBWClient: ...@@ -545,30 +545,38 @@ class UBWClient:
r = self.get(url, headers=headers) r = self.get(url, headers=headers)
return [models.Arbeidsordre.from_dict(x) for x in r] 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
def get_partial_arbeidsordrer(self, company_id: str) -> typing.List[models.PartialArbeidsordre]: # function
def get_partial_arbeidsordrer(
self, company_id: str
) -> typing.List[models.PartialArbeidsordre]:
url = self.urls.get_arbeidsordre(company_id) url = self.urls.get_arbeidsordre(company_id)
headers = self.config.rest.endpoints.begreper.headers headers = self.config.rest.endpoints.begreper.headers
r = self.get(url, r = self.get(
headers=headers, url,
params={ headers=headers,
'select': ','.join( params={
['companyId', "select": ",".join(
'workOrderId', [
'dateFrom', "companyId",
'dateTo', "workOrderId",
'periodFrom', "dateFrom",
'periodTo', "dateTo",
'status', "periodFrom",
'projectId', "periodTo",
'workOrderName', "status",
'costCentre', "projectId",
'projectManagerId', "workOrderName",
'category1', "costCentre",
'lastUpdated(updatedAt,updatedBy)'])}) "projectManagerId",
"category1",
"lastUpdated(updatedAt,updatedBy)",
]
)
},
)
return [models.PartialArbeidsordre.from_dict(x) for x in r] return [models.PartialArbeidsordre.from_dict(x) for x in r]
def get_perioder( def get_perioder(
self, self,
company_id: str, company_id: str,
......
...@@ -155,6 +155,7 @@ class Transaction(BaseModel): ...@@ -155,6 +155,7 @@ class Transaction(BaseModel):
voucher_no: int voucher_no: int
voucher_type: str voucher_type: str
ex_ref: typing.Optional[str] ex_ref: typing.Optional[str]
ext_inv_ref: typing.Optional[str]
ext_arch_ref_col: typing.Optional[str] ext_arch_ref_col: typing.Optional[str]
class Config: class Config:
...@@ -606,15 +607,6 @@ class Usage(BaseModel): ...@@ -606,15 +607,6 @@ class Usage(BaseModel):
allow_population_by_field_name = True 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): class Bruker(BaseModel):
user_id: str user_id: str
user_name: str user_name: str
...@@ -625,10 +617,12 @@ class Bruker(BaseModel): ...@@ -625,10 +617,12 @@ class Bruker(BaseModel):
language_code: typing.Optional[str] language_code: typing.Optional[str]
usage: typing.Optional[Usage] usage: typing.Optional[Usage]
contact_points: typing.Optional[typing.List[ContactPoint]] 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: class Config:
alias_generator = bruker_model_to_lower_camel alias_generator = to_lower_camel
allow_population_by_field_name = True allow_population_by_field_name = True
......
Supports Markdown
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