mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 19:33:12 +00:00
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
|
|
"""Tests for shared.ring_scheduler.update_queue_routing (ThreeCXClient faked)."""
|
||
|
|
|
||
|
|
import shared.ring_scheduler as ring_scheduler
|
||
|
|
|
||
|
|
|
||
|
|
class FakeThreeCXClient:
|
||
|
|
instances = []
|
||
|
|
|
||
|
|
def __init__(self, domain, auth_mode, client_id, client_secret):
|
||
|
|
self.domain = domain
|
||
|
|
self.auth_mode = auth_mode
|
||
|
|
self.client_id = client_id
|
||
|
|
self.client_secret = client_secret
|
||
|
|
self.forwarding = None
|
||
|
|
FakeThreeCXClient.instances.append(self)
|
||
|
|
|
||
|
|
def get_queue(self, number):
|
||
|
|
self.queue_number = number
|
||
|
|
return {"Id": 42, "Number": number}
|
||
|
|
|
||
|
|
def update_queue_forwarding(self, queue_id, closed, holiday):
|
||
|
|
self.forwarding = {"queue_id": queue_id, "closed": closed, "holiday": holiday}
|
||
|
|
return 200
|
||
|
|
|
||
|
|
|
||
|
|
def test_update_queue_routing_points_queue_at_extension(monkeypatch):
|
||
|
|
FakeThreeCXClient.instances = []
|
||
|
|
monkeypatch.setattr(ring_scheduler, "ThreeCXClient", FakeThreeCXClient)
|
||
|
|
|
||
|
|
result = ring_scheduler.update_queue_routing(
|
||
|
|
extension="114",
|
||
|
|
queue_number="800",
|
||
|
|
domain="test.3cx.us",
|
||
|
|
client_id="cid",
|
||
|
|
client_secret="secret",
|
||
|
|
)
|
||
|
|
|
||
|
|
assert result == {"extension": "114", "queue": "800"}
|
||
|
|
client = FakeThreeCXClient.instances[0]
|
||
|
|
assert client.auth_mode == "oauth"
|
||
|
|
assert client.queue_number == "800"
|
||
|
|
# Both closed and holiday routes point at the on-call extension.
|
||
|
|
assert client.forwarding == {"queue_id": 42, "closed": "114", "holiday": "114"}
|