Commit fbfacb9e authored by Jo Sama's avatar Jo Sama 😱
Browse files

Implements update_operator()

parent 0c13117b
......@@ -31,3 +31,16 @@ def test_create_operator(client,
sent_operator = Operator.from_json(object_sent)
assert(sent_operator == uncreated_operator)
def test_update_operator(client,
base_url,
requests_mock,
operator):
m = requests_mock.patch(client.urls.get_operator(operator.id))
client.update_operator(operator)
object_sent = m.request_history[-1].text
updated_operator = Operator.from_json(object_sent)
assert(updated_operator == operator)
......@@ -71,6 +71,9 @@ class TopDeskClient:
def put(self, url, **kwargs):
return self.call('PUT', url, **kwargs)
def patch(self, url, **kwargs):
return self.call('PATCH', url, **kwargs)
def get_operator(self, identity):
url = self.urls.get_operator(identity)
return Operator.from_dict(self.get(url))
......@@ -81,6 +84,12 @@ class TopDeskClient:
return_response=True,
data=operator.json())
def update_operator(self, operator):
url = self.urls.get_operator(operator.id)
self.patch(url,
return_response=True,
data=operator.json())
def list_operators(self):
for x in self.get(self.urls.get_operators()):
yield Operator.from_dict(x)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment