mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 04:33:10 +00:00
* feat(api): collapse Slack, portal, and jobs onto Fargate (PLAT-216) Move HTTP and scheduled work onto one always-on Flask task so after-hours loses Lambda cold start without changing the Cognito or roster contracts. * fix(portal-api): keep CORS headers on unexpected 500s Portal SPA error handling needs Access-Control-Allow-Origin even when DynamoDB or other internals fail, otherwise the browser hides the 500. * fix(api): retarget holidays per account and ship App Home changelog (PLAT-216) * fix(iam): list ECS tasks and fail closed on non-prod Paychex (PLAT-216) * fix(portal-api): serve portal JSON with an explicit JSON content type
47 lines
1.6 KiB
Python
47 lines
1.6 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 = []
|
|
|
|
def fake_oauth(domain, client_id, client_secret):
|
|
return FakeThreeCXClient(domain, "oauth", client_id, client_secret)
|
|
|
|
monkeypatch.setattr(ring_scheduler, "oauth_client", fake_oauth)
|
|
|
|
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"}
|