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
6229b6dc
Commit
6229b6dc
authored
Dec 02, 2020
by
Karen Bjørndalen
Browse files
Format code with black and change variable names in Ressurs model to snake_case
parent
3a64aee9
Pipeline
#47582
passed with stage
in 2 minutes and 17 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/conftest.py
View file @
6229b6dc
...
...
@@ -202,10 +202,12 @@ def pytest_collection_modifyitems(config, items):
if
"integration"
in
item
.
keywords
:
item
.
add_marker
(
skip_integration
)
@
pytest
.
fixture
def
ressurs_data
():
return
load_json_file
(
"ressurs.json"
)
@
pytest
.
fixture
def
ressurser_data
():
return
load_json_file
(
"ressurser.json"
)
tests/test_client.py
View file @
6229b6dc
...
...
@@ -360,14 +360,9 @@ def test_ubw_client_config():
endpoints
.
get_konteringsregel
(
"72"
,
12
)
==
"https://example.com/konteringsregler/v1/72/12"
)
assert
(
endpoints
.
get_ressurser
(
"72"
)
==
"https://example.com/ressurser/v1/72"
)
assert
(
endpoints
.
get_ressurser
(
"72"
,
12
)
==
"https://example.com/ressurser/v1/72/12"
)
assert
endpoints
.
get_ressurser
(
"72"
)
==
"https://example.com/ressurser/v1/72"
assert
endpoints
.
get_ressurser
(
"72"
,
12
)
==
"https://example.com/ressurser/v1/72/12"
def
test_map_transaction
():
transaction
=
Transaction
(
...
...
@@ -424,6 +419,7 @@ def test_map_transaction_null_dates():
assert
mapped
[
"DueDate"
]
==
null_date
assert
mapped
[
"ComplDelay"
]
==
null_date
def
test_get_ressurs
(
client
,
base_url
,
requests_mock
,
ressurs_data
):
company_id
=
"72"
ressurs_id
=
"99999"
...
...
@@ -435,6 +431,7 @@ def test_get_ressurs(client, base_url, requests_mock, ressurs_data):
expected
=
Ressurs
.
from_dict
(
ressurs_data
[
0
])
assert
expected
==
received
def
test_get_ressurser
(
client
,
base_url
,
requests_mock
,
ressurser_data
):
company_id
=
"72"
requests_mock
.
get
(
...
...
tests/test_client_intg.py
View file @
6229b6dc
...
...
@@ -316,7 +316,7 @@ def test_get_ressurser(service_config):
@
pytest
.
mark
.
integration
def
test_get_ressurs
(
service_config
):
person_id
=
"99999"
;
person_id
=
"99999"
client
=
get_client
(
**
service_config
)
ressurs
=
client
.
get_ressurs
(
"72"
,
person_id
)
assert
ressurs
...
...
tests/test_model.py
View file @
6229b6dc
...
...
@@ -85,13 +85,14 @@ def test_konto(konto_data):
assert
model
.
period_to
==
konto_data
[
0
][
"periodTo"
]
assert
model
.
status
==
konto_data
[
0
][
"status"
]
def
test_ressurs
(
ressurs_data
):
model
=
Ressurs
(
**
ressurs_data
[
0
])
assert
model
.
age
==
ressurs_data
[
0
][
"age"
]
assert
model
.
company
I
d
==
ressurs_data
[
0
][
"companyId"
]
assert
model
.
language
C
ode
==
ressurs_data
[
0
][
"languageCode"
]
assert
model
.
person
I
d
==
ressurs_data
[
0
][
"personId"
]
assert
model
.
person
N
ame
==
ressurs_data
[
0
][
"personName"
]
assert
model
.
personnel
T
ype
==
ressurs_data
[
0
][
"personnelType"
]
assert
model
.
company
_i
d
==
ressurs_data
[
0
][
"companyId"
]
assert
model
.
language
_c
ode
==
ressurs_data
[
0
][
"languageCode"
]
assert
model
.
person
_i
d
==
ressurs_data
[
0
][
"personId"
]
assert
model
.
person
_n
ame
==
ressurs_data
[
0
][
"personName"
]
assert
model
.
personnel
_t
ype
==
ressurs_data
[
0
][
"personnelType"
]
assert
model
.
status
==
ressurs_data
[
0
][
"status"
]
assert
model
.
workflow
S
tate
==
ressurs_data
[
0
][
"workflowState"
]
assert
model
.
workflow
_s
tate
==
ressurs_data
[
0
][
"workflowState"
]
tests/test_urls.py
View file @
6229b6dc
...
...
@@ -144,6 +144,7 @@ def test_konteringsregel_url_no_override_wo_trailing_slash(config_no_overrides):
url
=
client
.
urls
.
get_konteringsregel
(
"72"
,
"2"
)
assert
url
==
"https://example.com/base/konteringsregler/v1/72/2"
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
)
...
...
ubw_client/client.py
View file @
6229b6dc
...
...
@@ -112,7 +112,6 @@ class Endpoints:
str
(
konto
),
)
def
get_koststed
(
self
,
company_id
:
str
,
koststed
:
str
):
return
self
.
_prepend_base_url
(
self
.
rest
.
endpoints
.
koststeder
.
url
or
"koststeder/v1"
,
...
...
ubw_client/models.py
View file @
6229b6dc
...
...
@@ -855,18 +855,19 @@ class Konteringsregel(BaseModel):
alias_generator
=
to_lower_camel
allow_population_by_field_name
=
True
class
Ressurs
(
BaseModel
):
age
:
int
birth
D
ate
:
datetime
.
datetime
company
I
d
:
str
date
F
rom
:
datetime
.
datetime
date
T
o
:
datetime
.
datetime
language
C
ode
:
str
person
I
d
:
str
person
N
ame
:
str
personnel
T
ype
:
str
birth
_d
ate
:
datetime
.
datetime
company
_i
d
:
str
date
_f
rom
:
datetime
.
datetime
date
_t
o
:
datetime
.
datetime
language
_c
ode
:
str
person
_i
d
:
str
person
_n
ame
:
str
personnel
_t
ype
:
str
status
:
str
workflow
S
tate
:
str
workflow
_s
tate
:
str
class
Config
:
alias_generator
=
to_lower_camel
...
...
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