Commit 31efc0f5 authored by Jo Sama's avatar Jo Sama 😱
Browse files

Add method to link operator to operator filter

parent 73e8436b
......@@ -77,6 +77,15 @@ def test_update_operator(client,
assert _patch_operator_for_comparison(object_sent, operator) == operator
def test_link_operator_to_operator_filter(client,
requests_mock,
operator):
m = requests_mock.post(client.urls.get_operator_filter(operator.id),
status_code=204)
client.link_operator_to_operator_filter(operator, '9001')
object_sent = m.request_history[-1].json()
assert object_sent == [{'id': '9001'}]
def test_get_person_by_login_name(client,
base_url,
......
import logging
import requests
import uuid
import json
from typing import Optional, List, Iterator
from urllib.parse import urljoin, urlparse
......@@ -42,6 +43,9 @@ class Endpoints:
def get_operators(self):
return self._prepend_base_url('operators/')
def get_operator_filter(self, identity):
return urljoin(self.get_operator(identity) + '/', 'filters/operator')
def get_person(self, identity):
return urljoin(self._prepend_base_url('persons/id/'), identity)
......@@ -259,6 +263,17 @@ class TopDeskClient:
else:
return None
def link_operator_to_operator_filter(self, operator, filter_id):
url = self.urls.get_operator_filter(operator.id)
r = self.post(url,
headers={'Content-Type': 'application/json'},
return_response=True,
data=json.dumps([{'id': filter_id}]))
if r.status_code == 204:
return True
else:
return [x.get('message') for x in r.json()]
def list_operators(self):
for x in self.get(self.urls.get_operators()):
yield Operator.from_dict(x)
......
Markdown is supported
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