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
b2a89c65
Commit
b2a89c65
authored
Dec 16, 2020
by
Thomas.Nokling
Browse files
Om 40 bilagsart
parent
4ead7d73
Changes
11
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
b2a89c65
...
...
@@ -20,6 +20,8 @@ client = get_client(rest={'headers': {'X-Gravitee-Api-Key': '...',
'headers'
:
{
'X-Gravitee-Api-Key'
:
'key'
}},
# Ocp-Apim-Subscription-Key
'firma'
:
{
'headers'
:
{
'X-Gravitee-Api-Key'
:
'key'
}},
'bilagstyper'
:
{
'headers'
:
{
'X-Gravitee-Api-Key'
:
'key'
}},
'ressurser'
:
{
'headers'
:
{
'X-Gravitee-Api-Key'
:
'key'
}}}},
import_service
=
{
'credentials'
:
{
'client'
:
1
,
...
...
config.example.yaml
View file @
b2a89c65
...
...
@@ -33,6 +33,8 @@ rest:
url
:
konteringsregler/v1
koststeder
:
url
:
koststeder/v1
bilagstyper
:
url
:
bilagstyper/v1
avgiftskoder
:
url
:
avgiftskoder/v1
ressurser
:
...
...
tests/conftest.py
View file @
b2a89c65
...
...
@@ -34,6 +34,7 @@ def config(base_url):
"kontoplan"
:
{
"headers"
:
{}},
"konteringsregel"
:
{
"headers"
:
{}},
"konteringsregler"
:
{
"headers"
:
{}},
"bilagstyper"
:
{
"headers"
:
{}},
"ressurs"
:
{
"headers"
:
{}},
},
},
...
...
@@ -61,6 +62,7 @@ def config_no_overrides(base_url):
"kontoplan"
:
{},
"konteringsregel"
:
{},
"konteringsregler"
:
{},
"bilagstyper"
:
{},
"ressurs"
:
{},
},
},
...
...
@@ -142,6 +144,16 @@ def begrepsverdier_data():
return
load_json_file
(
"begrepsverdier.json"
)
@
pytest
.
fixture
def
bilagstype_data
():
return
load_json_file
(
"bilagstype.json"
)
@
pytest
.
fixture
def
bilagstyper_data
():
return
load_json_file
(
"bilagstyper.json"
)
@
pytest
.
fixture
def
project_data
():
return
load_json_file
(
"project.json"
)
...
...
tests/fixtures/bilagstype.json
0 → 100644
View file @
b2a89c65
[
{
"companyId"
:
"72"
,
"description"
:
"Timelister (TS13)"
,
"status"
:
"N"
,
"transactionSeries"
:
"TT"
,
"transactionType"
:
"TT"
,
"treatmentCode"
:
""
,
"updatedAt"
:
"2020-02-21T11:25:50.250"
,
"updatedBy"
:
"1100VSE"
}
]
tests/fixtures/bilagstyper.json
0 → 100644
View file @
b2a89c65
[
{
"companyId"
:
"72"
,
"description"
:
"Mottaksregistrert hovedboksbilag på flyt"
,
"status"
:
"N"
,
"transactionSeries"
:
"AI"
,
"transactionType"
:
"AI"
,
"treatmentCode"
:
"10"
,
"updatedAt"
:
"2020-09-08T11:26:14.990"
,
"updatedBy"
:
"R.AMBE"
},
{
"companyId"
:
"72"
,
"description"
:
"Reskontroføring manuelle innbetalinger"
,
"status"
:
"N"
,
"transactionSeries"
:
"MB"
,
"transactionType"
:
"AL"
,
"treatmentCode"
:
"3"
,
"updatedAt"
:
"2018-10-25T11:11:08.707"
,
"updatedBy"
:
"R.PAKL"
},
{
"companyId"
:
"72"
,
"description"
:
"Contempus leverandørfaktura"
,
"status"
:
"C"
,
"transactionSeries"
:
"CF"
,
"transactionType"
:
"CF"
,
"treatmentCode"
:
""
,
"updatedAt"
:
"2020-01-23T14:08:31.273"
,
"updatedBy"
:
"R.AMBE"
},
{
"companyId"
:
"72"
,
"description"
:
"Timelister (TS13)"
,
"status"
:
"N"
,
"transactionSeries"
:
"TT"
,
"transactionType"
:
"TT"
,
"treatmentCode"
:
""
,
"updatedAt"
:
"2020-02-21T11:25:50.250"
,
"updatedBy"
:
"1100VSE"
}
]
tests/test_client.py
View file @
b2a89c65
...
...
@@ -28,6 +28,7 @@ from ubw_client.models import (
Transaction
,
Avgiftskode
,
UbwRestBase
,
Bilagstype
,
)
...
...
@@ -382,6 +383,11 @@ def test_ubw_client_config():
endpoints
.
get_konteringsregel
(
"72"
,
12
)
==
"https://example.com/konteringsregler/v1/72/12"
)
assert
endpoints
.
get_bilagstyper
(
"72"
)
==
"https://example.com/bilagstyper/v1/72"
assert
(
endpoints
.
get_bilagstype
(
"72"
,
"TT"
)
==
"https://example.com/bilagstyper/v1/72/TT"
)
assert
endpoints
.
get_ressurser
(
"72"
)
==
"https://example.com/ressurser/v1/72"
assert
endpoints
.
get_ressurser
(
"72"
,
12
)
==
"https://example.com/ressurser/v1/72/12"
...
...
@@ -442,6 +448,30 @@ def test_map_transaction_null_dates():
assert
mapped
[
"ComplDelay"
]
==
null_date
def
test_get_bilagstyper
(
client
,
requests_mock
,
bilagstyper_data
):
company_id
=
"72"
requests_mock
.
get
(
f
"https://example.com/bilagstyper/v1/
{
company_id
}
"
,
json
=
bilagstyper_data
,
)
received
=
client
.
get_bilagstyper
(
company_id
)
expected
=
[
Bilagstype
.
from_dict
(
b
)
for
b
in
bilagstyper_data
]
assert
len
(
received
)
==
4
for
i
in
range
(
len
(
received
)):
assert
received
[
i
]
==
expected
[
i
]
def
test_get_bilagstype
(
client
,
requests_mock
,
bilagstype_data
):
company_id
=
"72"
transaction_type
=
"TT"
requests_mock
.
get
(
f
"https://example.com/bilagstyper/v1/
{
company_id
}
/
{
transaction_type
}
"
,
json
=
bilagstype_data
,
)
received
=
client
.
get_bilagstype
(
company_id
,
transaction_type
)
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"
...
...
tests/test_client_intg.py
View file @
b2a89c65
...
...
@@ -250,6 +250,25 @@ def test_get_prosjekter(service_config):
assert
prosjekt
[
0
].
related_values
[
0
].
relation_name
@
pytest
.
mark
.
integration
def
test_get_bilagstyper
(
service_config
):
client
=
get_client
(
**
service_config
)
bilagstyper
=
client
.
get_bilagstyper
(
"72"
)
assert
len
(
bilagstyper
)
>
3
for
bilagstype
in
bilagstyper
:
assert
bilagstype
.
companyId
==
"72"
@
pytest
.
mark
.
integration
def
test_get_bilagstype
(
service_config
):
transaction_type
=
"TT"
client
=
get_client
(
**
service_config
)
bilagstype
=
client
.
get_bilagstype
(
"72"
,
transaction_type
)
assert
bilagstype
assert
bilagstype
[
"transactionSeries"
]
==
"TT"
assert
bilagstype
[
"transactionType"
]
==
transaction_type
def
create_transactions
():
trans_list
=
[
{
...
...
tests/test_model.py
View file @
b2a89c65
...
...
@@ -11,6 +11,7 @@ from ubw_client.models import (
Periode
,
Prosjekt
,
UbwRestEndpoints
,
Bilagstype
,
Ressurs
,
)
...
...
@@ -86,6 +87,17 @@ def test_konto(konto_data):
assert
model
.
status
==
konto_data
[
0
][
"status"
]
def
test_bilagstype
(
bilagstype_data
):
model
=
Bilagstype
(
**
bilagstype_data
[
0
])
assert
model
.
company_id
==
bilagstype_data
[
0
][
"companyId"
]
assert
model
.
description
==
bilagstype_data
[
0
][
"description"
]
assert
model
.
status
==
bilagstype_data
[
0
][
"status"
]
assert
model
.
transaction_series
==
bilagstype_data
[
0
][
"transactionSeries"
]
assert
model
.
transaction_type
==
bilagstype_data
[
0
][
"transactionType"
]
assert
model
.
treatment_code
==
bilagstype_data
[
0
][
"treatmentCode"
]
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"
]
...
...
tests/test_urls.py
View file @
b2a89c65
...
...
@@ -145,6 +145,19 @@ def test_konteringsregel_url_no_override_wo_trailing_slash(config_no_overrides):
assert
url
==
"https://example.com/base/konteringsregler/v1/72/2"
def
test_bilagstyper_url_no_override_w_trailing_slash
(
config_no_overrides
):
config_no_overrides
[
"rest"
][
"base_url"
]
+=
"base/"
# trailing slash
client
=
get_client
(
**
config_no_overrides
)
url
=
client
.
urls
.
get_bilagstype
(
"72"
,
"TT"
)
assert
url
==
"https://example.com/base/bilagstyper/v1/72/TT"
def
test_bilagstyper_url_no_override_wo_trailing_slash
(
config_no_overrides
):
config_no_overrides
[
"rest"
][
"base_url"
]
+=
"base"
# no trailing slash
client
=
get_client
(
**
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
)
...
...
ubw_client/client.py
View file @
b2a89c65
...
...
@@ -119,6 +119,18 @@ class Endpoints:
koststed
,
)
def
get_bilagstyper
(
self
,
company_id
:
str
):
return
self
.
_prepend_base_url
(
self
.
rest
.
endpoints
.
bilagstyper
.
url
or
"bilagstyper/v1"
,
company_id
)
def
get_bilagstype
(
self
,
company_id
:
str
,
transaction_type
:
str
):
return
self
.
_prepend_base_url
(
self
.
rest
.
endpoints
.
bilagstyper
.
url
or
"bilagstyper/v1"
,
company_id
,
transaction_type
,
)
def
get_avgiftskode
(
self
,
company_id
:
str
,
avgiftskode
:
typing
.
Optional
[
str
]
=
None
):
...
...
@@ -666,6 +678,18 @@ class UBWClient:
response
=
self
.
get
(
url
,
headers
=
headers
)[
0
]
return
models
.
Konteringsregel
(
**
response
)
def
get_bilagstyper
(
self
,
company_id
:
str
)
->
typing
.
List
[
models
.
Bilagstype
]:
url
=
self
.
urls
.
get_bilagstyper
(
company_id
)
headers
=
self
.
config
.
rest
.
endpoints
.
bilagstyper
.
headers
response
=
self
.
get
(
url
,
headers
=
headers
)
return
[
models
.
Bilagstype
.
from_dict
(
b
)
for
b
in
response
]
def
get_bilagstype
(
self
,
company_id
:
str
,
ressurs_id
:
str
)
->
models
.
Bilagstype
:
url
=
self
.
urls
.
get_bilagstype
(
company_id
,
ressurs_id
)
headers
=
self
.
config
.
rest
.
endpoints
.
bilagstyper
.
headers
response
=
self
.
get
(
url
,
headers
=
headers
)[
0
]
return
models
.
Bilagstype
.
from_dict
(
response
)
def
get_avgiftskode
(
self
,
company_id
:
str
,
...
...
ubw_client/models.py
View file @
b2a89c65
...
...
@@ -81,6 +81,7 @@ class UbwRestEndpoints(BaseModel):
konteringsregler
:
UbwRestEndpoint
=
UbwRestEndpoint
()
konteringsregel
:
UbwRestEndpoint
=
UbwRestEndpoint
()
koststeder
:
UbwRestEndpoint
=
UbwRestEndpoint
()
bilagstyper
:
UbwRestEndpoint
=
UbwRestEndpoint
()
avgiftskoder
:
UbwRestEndpoint
=
UbwRestEndpoint
()
ressurser
:
UbwRestEndpoint
=
UbwRestEndpoint
()
...
...
@@ -317,6 +318,21 @@ class Aopartner(BaseModel):
pass
class
Bilagstype
(
BaseModel
):
company_id
:
str
description
:
str
status
:
str
transaction_series
:
str
transaction_type
:
str
treatment_code
:
str
updated_at
:
str
updated_by
:
str
class
Config
:
alias_generator
=
to_lower_camel
allow_population_by_field_name
=
True
class
CustomFieldGroups
(
BaseModel
):
probesk
:
Besk
prokontrakt
:
Contract
...
...
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