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
cim-client
Commits
a47de447
Commit
a47de447
authored
Nov 04, 2020
by
Trond Aasan
Browse files
CIM-27 Use entity specific function names
parent
0c5d1527
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
a47de447
...
...
@@ -10,8 +10,8 @@ c = CimClient(url='https://example.com',
delete_person_url
=
'/_webservices/?ws=contacts/delete/1.0'
,
tokens
=
{
'api_key'
:
{
'X-Gravitee-API-Key'
:
'c-d-a-b'
},})
upd_schema
=
c
.
get_update_schema
()
del_schema
=
c
.
get_delete_schema
()
upd_schema
=
c
.
get_update_
person_
schema
()
del_schema
=
c
.
get_delete_
person_
schema
()
person
=
Person
.
from_dict
({
'username'
:
'foo'
,
'user_import_id'
:
'foo1'
})
response1
=
c
.
update_person
(
person
)
...
...
cim_client/client.py
View file @
a47de447
...
...
@@ -71,10 +71,10 @@ class CimEndpoints:
def
delete_person
(
self
):
return
urllib
.
parse
.
urljoin
(
self
.
baseurl
,
self
.
delete_person_url
)
def
get_update_schema
(
self
):
def
get_update_
person_
schema
(
self
):
return
urllib
.
parse
.
urljoin
(
self
.
baseurl
,
self
.
update_person_url
)
def
get_delete_schema
(
self
):
def
get_delete_
person_
schema
(
self
):
return
urllib
.
parse
.
urljoin
(
self
.
baseurl
,
self
.
delete_person_url
)
...
...
@@ -171,7 +171,7 @@ class CimClient(object):
return
data
return
cls
.
from_dict
(
data
)
def
get_update_schema
(
self
):
def
get_update_
person_
schema
(
self
):
"""GETs the current schema from CIM
The schema can change depending on the installation.
...
...
@@ -180,13 +180,13 @@ class CimClient(object):
checks whether the schema has changed lately so you don't update
using an outdated schema.
"""
url
=
self
.
urls
.
get_update_schema
()
url
=
self
.
urls
.
get_update_
person_
schema
()
response
=
self
.
get
(
url
,
auth
=
self
.
auth
,
headers
=
self
.
tokens
.
get
(
'api_key'
,
None
))
return
response
.
json
()
def
get_delete_schema
(
self
):
def
get_delete_
person_
schema
(
self
):
"""GETs the current schema from CIM
The schema can change depending on the installation.
...
...
@@ -195,7 +195,7 @@ class CimClient(object):
checks whether the schema has changed lately so you don't update
using an outdated schema.
"""
url
=
self
.
urls
.
get_delete_schema
()
url
=
self
.
urls
.
get_delete_
person_
schema
()
response
=
self
.
get
(
url
,
auth
=
self
.
auth
,
headers
=
self
.
tokens
.
get
(
'api_key'
,
None
))
...
...
tests/test_client.py
View file @
a47de447
...
...
@@ -43,19 +43,19 @@ def test_init_modify_defaults(client_cls, baseurl, header_name):
assert
client
.
default_headers
[
header_name
]
!=
headers
[
header_name
]
def
test_get_update_schema
(
client
,
requests_mock
):
def
test_get_update_
person_
schema
(
client
,
requests_mock
):
"""Ensure getting update schema works"""
requests_mock
.
get
(
'https://localhost/_webservices/?ws=contacts/upsert/1.0'
,
json
=
{
'foo'
:
'bar'
})
response
=
client
.
get_update_schema
()
response
=
client
.
get_update_
person_
schema
()
assert
response
==
{
'foo'
:
'bar'
}
def
test_get_delete_schema
(
client
,
requests_mock
):
def
test_get_delete_
person_
schema
(
client
,
requests_mock
):
"""Ensure getting update schema works"""
requests_mock
.
get
(
'https://localhost/_webservices/?ws=contacts/delete/1.0'
,
json
=
{
'foo'
:
'bar'
})
response
=
client
.
get_delete_schema
()
response
=
client
.
get_delete_
person_
schema
()
assert
response
==
{
'foo'
:
'bar'
}
...
...
tests/test_endpoints.py
View file @
a47de447
...
...
@@ -16,13 +16,13 @@ def test_delete_person(baseurl, endpoints):
assert
url
==
baseurl
+
f
'/_webservices/?ws=contacts/delete/1.0'
def
test_get_update_schema
(
baseurl
,
endpoints
):
url
=
endpoints
.
get_update_schema
()
def
test_get_update_
person_
schema
(
baseurl
,
endpoints
):
url
=
endpoints
.
get_update_
person_
schema
()
assert
url
==
baseurl
+
f
'/_webservices/?ws=contacts/upsert/1.0'
def
test_get_delete_schema
(
baseurl
,
endpoints
):
url
=
endpoints
.
get_delete_schema
()
def
test_get_delete_
person_
schema
(
baseurl
,
endpoints
):
url
=
endpoints
.
get_delete_
person_
schema
()
assert
url
==
baseurl
+
f
'/_webservices/?ws=contacts/delete/1.0'
...
...
@@ -36,11 +36,11 @@ def test_custom_delete_person(custom_endpoints, baseurl):
baseurl
+
'/custom/_webservices/?ws=contacts/delete/1.0'
)
def
test_custom_get_update_schema
(
custom_endpoints
,
baseurl
):
assert
(
custom_endpoints
.
get_update_schema
()
==
def
test_custom_get_update_
person_
schema
(
custom_endpoints
,
baseurl
):
assert
(
custom_endpoints
.
get_update_
person_
schema
()
==
baseurl
+
'/custom/_webservices/?ws=contacts/upsert/1.0'
)
def
test_custom_get_delete_schema
(
custom_endpoints
,
baseurl
):
assert
(
custom_endpoints
.
get_delete_schema
()
==
def
test_custom_get_delete_
person_
schema
(
custom_endpoints
,
baseurl
):
assert
(
custom_endpoints
.
get_delete_
person_
schema
()
==
baseurl
+
'/custom/_webservices/?ws=contacts/delete/1.0'
)
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