Commit 8ca0cabc authored by Karen Bjørndalen's avatar Karen Bjørndalen
Browse files

Merge branch 'OM-41-ansattnr' into 'master'

Om 41 ansattnr

See merge request !53
parents fdaf6ca9 3d3541e3
Pipeline #48039 passed with stage
in 2 minutes and 14 seconds
......@@ -19,6 +19,8 @@ client = get_client(rest={'headers': {'X-Gravitee-Api-Key': '...',
'periode': {
'headers': {'X-Gravitee-Api-Key': 'key'}}, # Ocp-Apim-Subscription-Key
'firma': {
'headers': {'X-Gravitee-Api-Key': 'key'}},
'ressurser': {
'headers': {'X-Gravitee-Api-Key': 'key'}}}},
import_service={'credentials': {'client': 1,
'password': '<password>',
......
......@@ -35,6 +35,8 @@ rest:
url: koststeder/v1
avgiftskoder:
url: avgiftskoder/v1
ressurser:
url: ressurser/v1
import_service:
credentials:
......
......@@ -34,6 +34,7 @@ def config(base_url):
"kontoplan": {"headers": {}},
"konteringsregel": {"headers": {}},
"konteringsregler": {"headers": {}},
"ressurs": {"headers": {}},
},
},
"import_service": None,
......@@ -60,6 +61,7 @@ def config_no_overrides(base_url):
"kontoplan": {},
"konteringsregel": {},
"konteringsregler": {},
"ressurs": {},
},
},
"import_service": None,
......@@ -204,3 +206,13 @@ def pytest_collection_modifyitems(config, items):
for item in 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")
[
{
"age": 120,
"birthDate": "1900-01-01T00:00:00.000",
"companyId": "72",
"dateFrom": "2019-01-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"languageCode": "",
"personId": "99999",
"personName": "Dummy, Dummy",
"personnelType": "A",
"status": "N",
"workflowState": "",
"nameInformation": {
"aliasName": "DUMMY",
"customNameField1": "",
"customNameField2": "",
"customNameField3": "",
"customNameField4": "",
"customNamePart": "",
"firstName": "Dummy",
"surname": "Dummy",
"title": ""
},
"paymentInformation": {
"contractId": "",
"supplierId": ""
},
"additionalInformation": {
"hasOvertime": false,
"isHourlyPaid": false,
"piecework": false
},
"lastUpdated": {
"updatedAt": "2020-06-02T10:57:37.397",
"updatedBy": "1100VSE"
},
"contactPoints": [
{
"contactPointType": "1",
"address": {
"countryCode": "NO",
"place": "OSLO",
"postcode": "0001",
"province": "",
"streetAddress": ""
},
"phoneNumbers": {
"telephone1": "",
"telephone2": "",
"telephone3": "",
"telephone4": "",
"telephone5": "",
"telephone6": "",
"telephone7": ""
},
"additionalContactInfo": {
"contactPerson": "",
"contactPosition": "",
"eMail": "",
"eMailCc": "",
"gtin": "",
"url": ""
},
"lastUpdated": {
"updatedAt": "2019-11-18T15:16:51.000",
"updatedBy": "1100VSE"
}
}
],
"relatedValues": [
{
"dateFrom": "2020-01-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "11000000",
"relationGroup": "10",
"relationId": "C1",
"relationName": "KOSTSTED",
"unitValue": 0
}
],
"customFieldGroups": {}
}
]
[
{
"age": 120,
"birthDate": "1900-01-01T00:00:00.000",
"companyId": "72",
"dateFrom": "2019-01-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"languageCode": "",
"personId": "99999",
"personName": "Dummy, Dummy",
"personnelType": "A",
"status": "N",
"workflowState": "",
"nameInformation": {
"aliasName": "DUMMY",
"customNameField1": "",
"customNameField2": "",
"customNameField3": "",
"customNameField4": "",
"customNamePart": "",
"firstName": "Dummy",
"surname": "Dummy",
"title": ""
},
"paymentInformation": {
"contractId": "",
"supplierId": ""
},
"additionalInformation": {
"hasOvertime": false,
"isHourlyPaid": false,
"piecework": false
},
"lastUpdated": {
"updatedAt": "2020-06-02T10:57:37.397",
"updatedBy": "1100VSE"
},
"contactPoints": [
{
"contactPointType": "1",
"address": {
"countryCode": "NO",
"place": "OSLO",
"postcode": "0001",
"province": "",
"streetAddress": ""
},
"phoneNumbers": {
"telephone1": "",
"telephone2": "",
"telephone3": "",
"telephone4": "",
"telephone5": "",
"telephone6": "",
"telephone7": ""
},
"additionalContactInfo": {
"contactPerson": "",
"contactPosition": "",
"eMail": "",
"eMailCc": "",
"gtin": "",
"url": ""
},
"lastUpdated": {
"updatedAt": "2019-11-18T15:16:51.000",
"updatedBy": "1100VSE"
}
}
],
"relatedValues": [
{
"dateFrom": "2020-01-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "11000000",
"relationGroup": "10",
"relationId": "C1",
"relationName": "KOSTSTED",
"unitValue": 0
}
],
"customFieldGroups": {}
},
{
"age": 120,
"birthDate": "1900-01-01T00:00:00.000",
"companyId": "72",
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"languageCode": "",
"personId": "100500",
"personName": "D, Laila",
"personnelType": "A",
"status": "N",
"workflowState": "",
"nameInformation": {
"aliasName": "",
"customNameField1": "",
"customNameField2": "",
"customNameField3": "",
"customNameField4": "",
"customNamePart": "",
"firstName": "Laila",
"surname": "D",
"title": ""
},
"paymentInformation": {
"contractId": "",
"supplierId": ""
},
"additionalInformation": {
"hasOvertime": false,
"isHourlyPaid": false,
"piecework": false
},
"lastUpdated": {
"updatedAt": "2020-03-12T13:45:20.000",
"updatedBy": "R.ELSC"
},
"contactPoints": [
{
"contactPointType": "1",
"address": {
"countryCode": "NO",
"place": "OSLO",
"postcode": "0001",
"province": "",
"streetAddress": ""
},
"phoneNumbers": {
"telephone1": "",
"telephone2": "",
"telephone3": "",
"telephone4": "",
"telephone5": "",
"telephone6": "",
"telephone7": ""
},
"additionalContactInfo": {
"contactPerson": "",
"contactPosition": "",
"eMail": "A.B@NTNU.NO",
"eMailCc": "",
"gtin": "",
"url": ""
},
"lastUpdated": {
"updatedAt": "2020-02-05T10:51:21.273",
"updatedBy": "1100VSE"
}
}
],
"relatedValues": [
{
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "50001597",
"relationGroup": "10",
"relationId": "ZR05",
"relationName": "STILLINGSKAT",
"unitValue": 0
},
{
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "AD",
"relationGroup": "",
"relationId": "B3",
"relationName": "KOST.KAT",
"unitValue": 0
},
{
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "AD",
"relationGroup": "",
"relationId": "B2",
"relationName": "INNT.KAT",
"unitValue": 0
},
{
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "13000000",
"relationGroup": "10",
"relationId": "C1",
"relationName": "KOSTSTED",
"unitValue": 0
},
{
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "1364",
"relationGroup": "10",
"relationId": "ZZ04",
"relationName": "STILLINGSKODE",
"unitValue": 0
}
],
"customFieldGroups": {}
},
{
"age": 120,
"birthDate": "1900-01-01T00:00:00.000",
"companyId": "72",
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"languageCode": "",
"personId": "100501",
"personName": "S, Merete",
"personnelType": "A",
"status": "N",
"workflowState": "",
"nameInformation": {
"aliasName": "",
"customNameField1": "",
"customNameField2": "",
"customNameField3": "",
"customNameField4": "",
"customNamePart": "",
"firstName": "Merete",
"surname": "S",
"title": ""
},
"paymentInformation": {
"contractId": "",
"supplierId": ""
},
"additionalInformation": {
"hasOvertime": false,
"isHourlyPaid": false,
"piecework": false
},
"lastUpdated": {
"updatedAt": "2020-03-12T13:45:41.000",
"updatedBy": "R.ELSC"
},
"contactPoints": [
{
"contactPointType": "1",
"address": {
"countryCode": "NO",
"place": "OSLO",
"postcode": "0001",
"province": "",
"streetAddress": ""
},
"phoneNumbers": {
"telephone1": "",
"telephone2": "",
"telephone3": "",
"telephone4": "",
"telephone5": "",
"telephone6": "",
"telephone7": ""
},
"additionalContactInfo": {
"contactPerson": "",
"contactPosition": "",
"eMail": "A.B@NTNU.NO",
"eMailCc": "",
"gtin": "",
"url": ""
},
"lastUpdated": {
"updatedAt": "2020-02-05T10:51:21.290",
"updatedBy": "1100VSE"
}
}
],
"relatedValues": [
{
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "50001597",
"relationGroup": "10",
"relationId": "ZR05",
"relationName": "STILLINGSKAT",
"unitValue": 0
},
{
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "AD",
"relationGroup": "",
"relationId": "B3",
"relationName": "KOST.KAT",
"unitValue": 0
},
{
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "AD",
"relationGroup": "",
"relationId": "B2",
"relationName": "INNT.KAT",
"unitValue": 0
},
{
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "13000000",
"relationGroup": "10",
"relationId": "C1",
"relationName": "KOSTSTED",
"unitValue": 0
},
{
"dateFrom": "2019-08-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"percentage": 0,
"relatedValue": "1434",
"relationGroup": "10",
"relationId": "ZZ04",
"relationName": "STILLINGSKODE",
"unitValue": 0
}
],
"customFieldGroups": {}
}
]
\ No newline at end of file
......@@ -22,6 +22,7 @@ from ubw_client.models import (
Kontoplan,
Periode,
Prosjekt,
Ressurs,
ServerProcessResponse,
ServerProcessResult,
Transaction,
......@@ -381,6 +382,8 @@ 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"
def test_map_transaction():
......@@ -437,3 +440,28 @@ def test_map_transaction_null_dates():
assert mapped["DiscDate"] == null_date
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"
requests_mock.get(
f"https://example.com/ressurser/v1/{company_id}/{ressurs_id}",
json=ressurs_data,
)
received = client.get_ressurs(company_id, ressurs_id)
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(
f"https://example.com/ressurser/v1/{company_id}",
json=ressurser_data,
)
received = client.get_ressurser(company_id)
expected = [Ressurs.from_dict(b) for b in ressurser_data]
assert len(received) == 3
for i in range(len(received)):
assert received[i] == expected[i]
......@@ -303,3 +303,22 @@ def create_transactions():
]
return models.Transactions(__root__=trans_list)
@pytest.mark.integration
def test_get_ressurser(service_config):
client = get_client(**service_config)
ressurser = client.get_ressurser("72")
assert len(ressurser) > 3
for ressurs in ressurser:
assert ressurs.companyId == "72"
@pytest.mark.integration
def test_get_ressurs(service_config):
person_id = "99999"
client = get_client(**service_config)
ressurs = client.get_ressurs("72", person_id)
assert ressurs
assert ressurs["personName"] == "Dummy, Dummy"
assert ressurs["personId"] == person_id
......@@ -11,6 +11,7 @@ from ubw_client.models import (
Periode,
Prosjekt,
UbwRestEndpoints,
Ressurs,
)
......@@ -83,3 +84,15 @@ def test_konto(konto_data):
assert model.period_from == konto_data[0]["periodFrom"]
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_id == ressurs_data[0]["companyId"]
assert model.language_code == ressurs_data[0]["languageCode"]
assert model.person_id == ressurs_data[0]["personId"]
assert model.person_name == ressurs_data[0]["personName"]
assert model.personnel_type == ressurs_data[0]["personnelType"]
assert model.status == ressurs_data[0]["status"]
assert model.workflow_state == ressurs_data[0]["workflowState"]
......@@ -143,3 +143,17 @@ def test_konteringsregel_url_no_override_wo_trailing_slash(config_no_overrides):
client = get_client(**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)
url = client.urls.get_ressurser("72", "2")
assert url == "https://example.com/base/ressurser/v1/72/2"
def test_ressurser_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_ressurser("72", "2")
assert url == "https://example.com/base/ressurser/v1/72/2"
......@@ -128,6 +128,11 @@ class Endpoints:
avgiftskode,
)
def get_ressurser(self, company_id: str, ressurs_id: typing.Optional[str] = None):
return self._prepend_base_url(
self.rest.endpoints.ressurser.url or "ressurser/v1", company_id, ressurs_id
)
def _create_transaction_report(
transaction_result_response,
......@@ -669,6 +674,18 @@ class UBWClient:
response = self.get(url, params=params, headers=headers)
return [models.Avgiftskode(**x) for x in response]
def get_ressurser(self, company_id: str) -> typing.List[models.Ressurs]:
url = self.urls.get_ressurser(company_id)
headers = self.config.rest.endpoints.ressurser.headers
response = self.get(url, headers=headers)
return [models.Ressurs.from_dict(b) for b in response]
def get_ressurs(self, company_id: str, ressurs_id: str) -> models.Ressurs:
url = self.urls.get_ressurser(company_id, ressurs_id)
headers = self.config.rest.endpoints.ressurser.headers
response = self.get(url, headers=headers)[0]
return models.Ressurs.<