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
topdesk-client
Commits
52311e92
Commit
52311e92
authored
Jun 29, 2021
by
Andreas Ellewsen
Browse files
Add support for incidents
Implements post and get for single incidents with associated models and tests.
parent
63c7a169
Changes
11
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
52311e92
...
...
@@ -182,3 +182,6 @@ tags
# End of https://www.gitignore.io/api/vim,python,sublimetext
# Vscode settings
.vscode/
config.yaml
README.md
View file @
52311e92
# Client for the TOPdesk REST APIs
# Testing
Run unit tests with
```
bash
python
-m
pytest .
```
To include integration tests you will have to create a config.yaml file with content
```
yaml
url
:
"
http://url/to/actual/endpoint/"
headers
:
{
"
X-Gravitee-Api-Key"
:
"
your-api-key"
}
```
and then run pytest with
```
bash
python
-m
pytest
-m
"integration"
.
```
pytest.ini
0 → 100644
View file @
52311e92
[pytest]
markers
=
integration:
mark
a
test
as
a
integration-test.
requirements-test.txt
View file @
52311e92
tox
pytest
requests_mock
pyyaml
tests/conftest.py
View file @
52311e92
...
...
@@ -2,6 +2,8 @@ import pytest
import
os
import
json
import
yaml
from
topdesk_client
import
get_client
from
topdesk_client.models
import
Operator
,
Person
...
...
@@ -20,6 +22,13 @@ def config(base_url):
}
@
pytest
.
fixture
def
integration_test_config
():
with
open
(
"config.yaml"
)
as
f
:
config_file
=
f
.
read
()
return
yaml
.
load
(
config_file
,
Loader
=
yaml
.
FullLoader
)
@
pytest
.
fixture
def
client
(
config
):
return
get_client
(
config
)
...
...
@@ -88,3 +97,26 @@ def uncreated_person():
@
pytest
.
fixture
def
person_list_data
():
return
load_json_file
(
'person_list.json'
)
@
pytest
.
fixture
def
incident_create_body
():
return
load_json_file
(
"incident_create_body.json"
)
@
pytest
.
fixture
def
incident_response
():
return
load_json_file
(
"incident_response.json"
)
def
pytest_collection_modifyitems
(
config
,
items
):
"""Modify collection to skip tests marked with integration."""
if
config
.
option
.
keyword
or
config
.
option
.
markexpr
:
return
skip_integration
=
pytest
.
mark
.
skip
(
reason
=
'Not running with pytest -m "integration"'
)
for
item
in
items
:
if
"integration"
in
item
.
keywords
:
item
.
add_marker
(
skip_integration
)
tests/fixtures/incident_create_body.json
0 → 100644
View file @
52311e92
{
"caller"
:
{
"branch"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
"dynamicName"
:
"string"
,
"phoneNumber"
:
"string"
,
"mobileNumber"
:
"string"
,
"email"
:
"string"
,
"department"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"locations"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
"budgetHolder"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"personExtraFieldA"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"personExtraFieldB"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
}
},
"callerLookup"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
"status"
:
"firstLine"
,
"briefDescription"
:
"string"
,
"request"
:
"string"
,
"action"
:
"string"
,
"actionInvisibleForCaller"
:
false
,
"entryType"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"callType"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"category"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"subcategory"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"externalNumber"
:
"string"
,
"object"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"location"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
"branch"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
"mainIncident"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"number"
:
"string"
},
"impact"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"urgency"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"priority"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"duration"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"targetDate"
:
{
"id"
:
"2021-06-30T06:28:14.282Z"
},
"sla"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
"onHold"
:
true
,
"operator"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
"operatorGrpoup"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
"supplier"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
"processingStatus"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"responded"
:
true
,
"responseDate"
:
"2021-06-30T06:28:14.282Z"
,
"completed"
:
true
,
"completedDate"
:
"2021-06-30T06:28:14.282Z"
,
"closed"
:
true
,
"closedDate"
:
"2021-06-30T06:28:14.282Z"
,
"closureCode"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"costs"
:
0.15
,
"feedbackRating"
:
2
,
"feedbackMessage"
:
"string"
,
"majorCall"
:
true
,
"majorCallObject"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"publishToSsd"
:
true
,
"optionalFields1"
:
{
"boolean1"
:
true
,
"boolean2"
:
true
,
"boolean3"
:
true
,
"boolean4"
:
true
,
"boolean5"
:
true
,
"number1"
:
54
,
"number2"
:
54
,
"number3"
:
54
,
"number4"
:
54
,
"number5"
:
54
,
"text1"
:
"this is some text"
,
"text2"
:
"this is some text"
,
"text3"
:
"this is some text"
,
"text4"
:
"this is some text"
,
"text5"
:
"this is some text"
,
"memo1"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo1"
,
"memo2"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo2"
,
"memo3"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo3"
,
"memo4"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo4"
,
"memo5"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo5"
,
"date1"
:
"2015-11-25T08:58:47.863+0000"
,
"date2"
:
"2015-11-25T08:58:47.863+0000"
,
"date3"
:
"2015-11-25T08:58:47.863+0000"
,
"date4"
:
"2015-11-25T08:58:47.863+0000"
,
"date5"
:
"2015-11-25T08:58:47.863+0000"
,
"searchlist1"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist2"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist3"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist4"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist5"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
}
},
"optionalFields2"
:
{
"boolean1"
:
true
,
"boolean2"
:
true
,
"boolean3"
:
true
,
"boolean4"
:
true
,
"boolean5"
:
true
,
"number1"
:
54
,
"number2"
:
54
,
"number3"
:
54
,
"number4"
:
54
,
"number5"
:
54
,
"text1"
:
"this is some text"
,
"text2"
:
"this is some text"
,
"text3"
:
"this is some text"
,
"text4"
:
"this is some text"
,
"text5"
:
"this is some text"
,
"memo1"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo1"
,
"memo2"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo2"
,
"memo3"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo3"
,
"memo4"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo4"
,
"memo5"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo5"
,
"date1"
:
"2015-11-25T08:58:47.863+0000"
,
"date2"
:
"2015-11-25T08:58:47.863+0000"
,
"date3"
:
"2015-11-25T08:58:47.863+0000"
,
"date4"
:
"2015-11-25T08:58:47.863+0000"
,
"date5"
:
"2015-11-25T08:58:47.863+0000"
,
"searchlist1"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist2"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist3"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist4"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist5"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
}
},
"externalLink"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"type"
:
"string"
,
"date"
:
"string"
}
}
tests/fixtures/incident_response.json
0 → 100644
View file @
52311e92
{
"id"
:
"f197bb75-8822-45e9-82ce-02983504020b"
,
"status"
:
"firstLine"
,
"number"
:
"I 2011 007"
,
"request"
:
"string"
,
"requests"
:
"string"
,
"action"
:
"string"
,
"attachments"
:
"string"
,
"caller"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"dynamicName"
:
"string"
,
"email"
:
"string"
,
"mobileNumber"
:
"string"
,
"phoneNumber"
:
"string"
,
"branch"
:
{
"clientReferenceNumber"
:
"string"
,
"timeZone"
:
"string"
,
"extraA"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"extraB"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"department"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"budgetHolder"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
}
},
"callerBranch"
:
{
"clientReferenceNumber"
:
"string"
,
"timeZone"
:
"string"
,
"extraA"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"extraB"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"branchExtraFieldA"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"branchExtraFieldB"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"briefDescription"
:
"string"
,
"category"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"subcategory"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"callType"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"entryType"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"object"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
,
"type"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"make"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"model"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"branch"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"location"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"specification"
:
"string"
,
"serialNumber"
:
"string"
},
"asset"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
"branch"
:
{
"clientReferenceNumber"
:
"string"
,
"timeZone"
:
"string"
,
"extraA"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"extraB"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"location"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"branch"
:
{
"clientReferenceNumber"
:
"string"
,
"timeZone"
:
"string"
,
"extraA"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"extraB"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"name"
:
"string"
,
"room"
:
"string"
},
"impact"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"urgency"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"priority"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"duration"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"actualDuration"
:
0
,
"targetDate"
:
"2021-06-30T06:46:55.117Z"
,
"sla"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"responseTargetDate"
:
"2021-06-30T06:46:55.117Z"
,
"targetDate"
:
"2021-06-30T06:46:55.117Z"
},
"responseDate"
:
"2021-06-30T06:46:55.117Z"
,
"onHold"
:
true
,
"onHoldDate"
:
"2021-06-30T06:46:55.117Z"
,
"onHoldDuration"
:
0
,
"feedbackMessage"
:
"string"
,
"feedbackRating"
:
0
,
"operator"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"status"
:
"operator"
,
"name"
:
"string"
},
"operatorGroup"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"supplier"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
,
"forFirstLine"
:
true
,
"forSecondLine"
:
true
},
"processingStatus"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"completed"
:
true
,
"completedDate"
:
"2021-06-30T06:46:55.118Z"
,
"closed"
:
true
,
"closedDate"
:
"2021-06-30T06:46:55.118Z"
,
"closureCode"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"timeSpent"
:
0
,
"timeSpentFirstLine"
:
0
,
"timeSpentSecondLineAndPartials"
:
0
,
"itemCosts"
:
0
,
"objectCosts"
:
0
,
"costs"
:
0
,
"escalationStatus"
:
"Escalated"
,
"escalationReason"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"escalationOperator"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"callDate"
:
"2021-06-30T06:46:55.118Z"
,
"creator"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"creationDate"
:
"2021-06-30T06:46:55.118Z"
,
"modifier"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"modificationDate"
:
"2021-06-30T06:46:55.118Z"
,
"archivingReason"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"majorCall"
:
true
,
"majorCallObject"
:
{
"name"
:
"string"
,
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"status"
:
0
,
"majorIncident"
:
true
},
"publishToSsd"
:
true
,
"monitored"
:
true
,
"responded"
:
true
,
"expectedTimeSpent"
:
0
,
"mainIncident"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"number"
:
"string"
},
"partialIncidents"
:
[
{
"link"
:
"string"
}
],
"optionalFields1"
:
{
"boolean1"
:
true
,
"boolean2"
:
true
,
"boolean3"
:
true
,
"boolean4"
:
true
,
"boolean5"
:
true
,
"number1"
:
54
,
"number2"
:
54
,
"number3"
:
54
,
"number4"
:
54
,
"number5"
:
54
,
"text1"
:
"this is some text"
,
"text2"
:
"this is some text"
,
"text3"
:
"this is some text"
,
"text4"
:
"this is some text"
,
"text5"
:
"this is some text"
,
"memo1"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo1"
,
"memo2"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo2"
,
"memo3"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo3"
,
"memo4"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo4"
,
"memo5"
:
"26-02-2016 08:44 [GMT +1:00] Meadows, D. Sr.:
\n
Memo5"
,
"date1"
:
"2015-11-25T08:58:47.863+0000"
,
"date2"
:
"2015-11-25T08:58:47.863+0000"
,
"date3"
:
"2015-11-25T08:58:47.863+0000"
,
"date4"
:
"2015-11-25T08:58:47.863+0000"
,
"date5"
:
"2015-11-25T08:58:47.863+0000"
,
"searchlist1"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist2"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist3"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist4"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"
},
"searchlist5"
:
{
"id"
:
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
,
"name"
:
"string"